diff --git a/.github/actions/run-tests/action.yml b/.github/actions/run-tests/action.yml new file mode 100644 index 00000000..6ae41b16 --- /dev/null +++ b/.github/actions/run-tests/action.yml @@ -0,0 +1,130 @@ +name: 'Run NRedisStack tests' +description: 'Runs NRedisStack tests against different Redis versions and configurations' +inputs: + dotnet-version: + description: 'SDK version' + required: true + redis-version: + description: 'Redis version to test against' + required: true + verify-nuget-package: + description: 'Verify Nuget package' + required: false + default: 'false' + REDIS_CA_PEM: + description: 'Redis CA PEM' + required: true + REDIS_USER_CRT: + description: 'Redis User CRT' + required: true + REDIS_USER_PRIVATE_KEY: + description: 'Redis User Private Key' + required: true +runs: + using: "composite" + steps: + - uses: actions/checkout@v4 + + - name: Install .NET Core + uses: actions/setup-dotnet@v4 + with: + dotnet-version: ${{inputs.dotnet-version}} + dotnet-quality: 'ga' + + - name: Setup Environment variables and run Redis + env: + REDIS_VERSION: ${{ inputs.redis-version }} + REDIS_IMAGE: "redis:${{ inputs.redis-version }}" + CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}" + run: | + set -e + + dotnet_major_minor_version=$(echo "${{ inputs.dotnet-version }}" | grep -oP '^\d+\.\d+') + echo "CLR_VERSION=net${dotnet_major_minor_version}" >> $GITHUB_ENV + + redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+') + echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV + + if (( redis_major_version < 8 )); then + echo "Using redis-stack for module tests" + + # Mapping of redis version to stack version + declare -A redis_stack_version_mapping=( + ["7.4.1"]="rs-7.4.0-v1" + ["7.2.6"]="rs-7.2.0-v13" + ["6.2.16"]="rs-6.2.6-v17" + ) + + if [[ -v redis_stack_version_mapping[$REDIS_VERSION] ]]; then + export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:${redis_stack_version_mapping[$REDIS_VERSION]}" + else + echo "Version not found in the mapping." + exit 1 + fi + + if (( redis_major_version < 7 )); then + export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''" + fi + + docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build + else + echo "Using redis CE for module tests" + export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:$REDIS_VERSION" + docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build + fi + shell: bash + + # Make sure only the desired dotnet version is set both as target and as active SDK. + - name: Tweak target frameworks + shell: bash + run: | + find . -name '*.csproj' | xargs -I {} sed -E -i "s|.*|${CLR_VERSION}|" {} + find . -name '*.csproj' | xargs cat + jq -n --arg version ${{inputs.dotnet-version}} '{"sdk":{"version":$version,"rollForward":"latestMinor"}}' > global.json + - name: Check .NET version + shell: bash + run: dotnet --version + - name: Check .NET SDKs + shell: bash + run: dotnet --list-sdks + - name: Check .NET runtimes + shell: bash + run: dotnet --list-runtimes + - name: Restore dependencies + shell: bash + run: dotnet restore + + - name: Build + shell: bash + run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true + + - name: Test + shell: bash + run: | + echo "${{inputs.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_ca.pem + echo "${{inputs.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user.crt + echo "${{inputs.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user_private.key + dotnet test -f ${CLR_VERSION} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -p:BuildInParallel=false tests/Test.proj --logger GitHubActions + - name: Codecov + uses: codecov/codecov-action@v4 + with: + verbose: true + - name: Build + shell: bash + run: dotnet pack -c Release + + - name: Test against Nuget package from local source + if: inputs.verify-nuget-package == 'true' + working-directory: PackageVerification + shell: bash + run: | + mkdir -p test-source + dotnet nuget add source $(readlink -f test-source) -n test-source + find .. -name '*.nupkg' | xargs -I {} dotnet nuget push {} -s test-source + ls -R + dotnet nuget remove source nuget.org + dotnet nuget list source + find . -name '*.csproj' | xargs -I {} sed -E -i 's|.*|${CLR_VERSION}|' {} + dotnet restore -s test-source -v detailed + dotnet run + diff --git a/.github/dockers/Dockerfile.cluster b/.github/dockers/Dockerfile.cluster deleted file mode 100644 index 3a0d7341..00000000 --- a/.github/dockers/Dockerfile.cluster +++ /dev/null @@ -1,7 +0,0 @@ -FROM redis/redis-stack-server:edge as rss - -COPY dockers/create_cluster.sh /create_cluster.sh -RUN ls -R /opt/redis-stack -RUN chmod a+x /create_cluster.sh - -ENTRYPOINT [ "/create_cluster.sh"] diff --git a/.github/dockers/cluster.redis.conf b/.github/dockers/cluster.redis.conf deleted file mode 100644 index 901d17ae..00000000 --- a/.github/dockers/cluster.redis.conf +++ /dev/null @@ -1,8 +0,0 @@ -protected-mode no -enable-debug-command yes -loadmodule /opt/redis-stack/lib/redisearch.so -# loadmodule /opt/redis-stack/lib/redisgraph.so -loadmodule /opt/redis-stack/lib/redistimeseries.so -loadmodule /opt/redis-stack/lib/rejson.so -loadmodule /opt/redis-stack/lib/redisbloom.so -loadmodule /opt/redis-stack/lib/redisgears.so v8-plugin-path /opt/redis-stack/lib/libredisgears_v8_plugin.so diff --git a/.github/dockers/create_cluster.sh b/.github/dockers/create_cluster.sh deleted file mode 100644 index da9a0cb6..00000000 --- a/.github/dockers/create_cluster.sh +++ /dev/null @@ -1,47 +0,0 @@ -#! /bin/bash - -mkdir -p /nodes -touch /nodes/nodemap -if [ -z ${START_PORT} ]; then - START_PORT=16379 -fi -if [ -z ${END_PORT} ]; then - END_PORT=16384 -fi -if [ ! -z "$3" ]; then - START_PORT=$2 - START_PORT=$3 -fi -echo "STARTING: ${START_PORT}" -echo "ENDING: ${END_PORT}" - -for PORT in `seq ${START_PORT} ${END_PORT}`; do - mkdir -p /nodes/$PORT - if [[ -e /redis.conf ]]; then - cp /redis.conf /nodes/$PORT/redis.conf - else - touch /nodes/$PORT/redis.conf - fi - cat << EOF >> /nodes/$PORT/redis.conf -port ${PORT} -cluster-enabled yes -daemonize yes -logfile /redis.log -dir /nodes/$PORT -EOF - - set -x - /opt/redis-stack/bin/redis-server /nodes/$PORT/redis.conf - sleep 1 - if [ $? -ne 0 ]; then - echo "Redis failed to start, exiting." - continue - fi - echo 127.0.0.1:$PORT >> /nodes/nodemap -done -if [ -z "${REDIS_PASSWORD}" ]; then - echo yes | /opt/redis-stack/bin/redis-cli --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 -else - echo yes | opt/redis-stack/bin/redis-cli -a ${REDIS_PASSWORD} --cluster create `seq -f 127.0.0.1:%g ${START_PORT} ${END_PORT}` --cluster-replicas 1 -fi -tail -f /redis.log diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 0b5d6027..5b1276a0 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -15,164 +15,83 @@ concurrency: group: ${{ github.event.pull_request.number || github.ref }}-integration cancel-in-progress: true -jobs: - enterprise-tests: - name: Redis Enterprise - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - enterprise_version: ['7.4.2-54'] - env_file_mode: ['enterprise', 'enterprise_oss_cluster'] - - steps: - - uses: actions/checkout@v4 - - - name: Load dotnenv for CI - uses: xom9ikk/dotenv@v2 - with: - path: .github/workflows/modes - mode: ${{ matrix.env_file_mode }} - - - name: Clone ee docker code - uses: actions/checkout@v4 - with: - repository: redislabs/redis-ee-docker - path: redis-ee-docker - - - name: Start docker - working-directory: redis-ee-docker - env: - IMAGE: redislabs/redis:${{ matrix.enterprise_version }} - run: ./build.sh - - - name: .NET Core 8 - uses: actions/setup-dotnet@v2 - with: - dotnet-version: '8.0.x' - - - name: Restore dependencies - run: dotnet restore - - - name: Build - run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true +env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + REDIS_IMAGE: redis:latest + REDIS_STACK_IMAGE: redis/redis-stack-server:latest + CURRENT_REDIS_VERSION: '7.4.1' - - name: Test - run: dotnet test -f net8.0 --no-build --verbosity detailed -p:BuildInParallel=false tests/Test.proj --logger GitHubActions - - dotnet_6_cluster: - name: .NET 6 on [redis-stack cluster] - uses: ./.github/workflows/reusable.yml - with: - redis_stack_type: cluster - clr_version: net6.0 - mode: oss_cluster - dotnet_sdk_version: 6.0.0 - secrets: inherit - - dotnet_6: - name: .NET 6 on [redis-stack ${{matrix.redis-stack-type}}] - uses: ./.github/workflows/reusable.yml - strategy: - fail-fast: false - max-parallel: 5 - matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] - with: - redis_stack_type: ${{matrix.redis-stack-type}} - clr_version: net6.0 - mode: standalone - dotnet_sdk_version: 6.0.0 - secrets: inherit - - dotnet_7_cluster: - name: .NET 7 on [redis-stack cluster] - uses: ./.github/workflows/reusable.yml - with: - redis_stack_type: cluster - clr_version: net7.0 - mode: oss_cluster - dotnet_sdk_version: 7.0.0 - secrets: inherit - - dotnet_7: - name: .NET 7 on [redis-stack ${{matrix.redis-stack-type}}] - uses: ./.github/workflows/reusable.yml - strategy: - fail-fast: false - max-parallel: 5 - matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] - with: - redis_stack_type: ${{matrix.redis-stack-type}} - clr_version: net7.0 - mode: standalone - dotnet_sdk_version: 7.0.0 - secrets: inherit - - dotnet_8_cluster: - name: .NET 8 on [redis-stack cluster] - uses: ./.github/workflows/reusable.yml - with: - redis_stack_type: cluster - clr_version: net8.0 - mode: oss_cluster - dotnet_sdk_version: 8.0.0 - secrets: inherit - - dotnet_8: - name: .NET 8 on [redis-stack ${{matrix.redis-stack-type}}] - uses: ./.github/workflows/reusable.yml - strategy: - fail-fast: false - max-parallel: 5 - matrix: - redis-stack-type: ['edge', '6.2.6', '7.2.0-RC3'] - with: - redis_stack_type: ${{matrix.redis-stack-type}} - clr_version: net8.0 - mode: standalone - dotnet_sdk_version: 8.0.0 - secrets: inherit - - build_and_test_windows: - name: Windows Test ${{matrix.redis-stack-version}} - runs-on: windows-latest - strategy: - fail-fast: false - matrix: - redis-stack-version: ['6.2.6-v9', '7.2.0-RC3'] - env: - redis_stack_version: ${{matrix.redis-stack-version}} - USER_NAME: ${{ secrets.USER_NAME }} - PASSWORD: ${{ secrets.PASSWORD }} - ENDPOINT: ${{ secrets.ENDPOINT }} - steps: - - uses: actions/checkout@v3 - - uses: Vampire/setup-wsl@v2 - with: - distribution: Ubuntu-22.04 - - name: Install Redis - shell: wsl-bash {0} - run: | - sudo apt-get update - sudo apt-get install curl -y && sudo apt-get install gpg -y && apt-get install lsb-release -y && apt-get install libgomp1 -y - curl https://packages.redis.io/redis-stack/redis-stack-server-${{env.redis_stack_version}}.jammy.x86_64.tar.gz -o redis-stack.tar.gz - tar xf redis-stack.tar.gz - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true - - name: Save test certificates - shell: wsl-bash {0} - run: | - echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net481/redis_ca.pem - echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net481/redis_user.crt - echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net481/redis_user_private.key - ls -R - - name: Test - shell: cmd - run: | - START wsl ./redis-stack-server-${{env.redis_stack_version}}/bin/redis-stack-server & - dotnet test -f net481 --no-build --verbosity detailed -p:BuildInParallel=false tests/Test.proj --logger GitHubActions +jobs: + redis_version: + runs-on: ubuntu-latest + outputs: + CURRENT: ${{ env.CURRENT_REDIS_VERSION }} + steps: + - name: Compute outputs + run: | + echo "CURRENT=${{ env.CURRENT_REDIS_VERSION }}" >> $GITHUB_OUTPUT + + tests: + runs-on: ubuntu-latest + timeout-minutes: 60 + needs: redis_version + strategy: + max-parallel: 15 + fail-fast: false + matrix: + redis-version: [ '${{ needs.redis_version.outputs.CURRENT }}', '7.2.6', '6.2.16'] + dotnet-version: ['6.0', '7.0', '8.0'] + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + name: Redis ${{ matrix.redis-version }}; .NET ${{ matrix.dotnet-version }}; + steps: + - uses: actions/checkout@v4 + - name: Run tests + uses: ./.github/actions/run-tests + with: + dotnet-version: ${{ matrix.dotnet-version }} + redis-version: ${{ matrix.redis-version }} + REDIS_CA_PEM: ${{ secrets.REDIS_CA_PEM }} + REDIS_USER_CRT: ${{ secrets.REDIS_USER_CRT }} + REDIS_USER_PRIVATE_KEY: ${{ secrets.REDIS_USER_PRIVATE_KEY }} + + build_and_test_windows: + name: Windows Test ${{matrix.redis-stack-version}} + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + redis-stack-version: ['6.2.6-v9', '7.2.0-RC3'] + env: + redis_stack_version: ${{matrix.redis-stack-version}} + USER_NAME: ${{ secrets.USER_NAME }} + PASSWORD: ${{ secrets.PASSWORD }} + ENDPOINT: ${{ secrets.ENDPOINT }} + steps: + - uses: actions/checkout@v3 + - uses: Vampire/setup-wsl@v2 + with: + distribution: Ubuntu-22.04 + - name: Install Redis + shell: wsl-bash {0} + run: | + sudo apt-get update + sudo apt-get install curl -y && sudo apt-get install gpg -y && apt-get install lsb-release -y && apt-get install libgomp1 -y + curl https://packages.redis.io/redis-stack/redis-stack-server-${{env.redis_stack_version}}.jammy.x86_64.tar.gz -o redis-stack.tar.gz + tar xf redis-stack.tar.gz + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true + - name: Save test certificates + shell: wsl-bash {0} + run: | + echo "${{secrets.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/net481/redis_ca.pem + echo "${{secrets.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/net481/redis_user.crt + echo "${{secrets.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/net481/redis_user_private.key + ls -R + - name: Test + shell: cmd + run: | + START wsl ./redis-stack-server-${{env.redis_stack_version}}/bin/redis-stack-server & + dotnet test -f net481 --no-build --verbosity detailed -p:BuildInParallel=false tests/Test.proj --logger GitHubActions diff --git a/.github/workflows/modes/.env.enterprise b/.github/workflows/modes/.env.enterprise deleted file mode 100644 index 9a57f7f5..00000000 --- a/.github/workflows/modes/.env.enterprise +++ /dev/null @@ -1,7 +0,0 @@ -REDIS=127.0.0.1:6379 -IS_ENTERPRISE=true -RE_USERNAME=test@test.com -RE_PASS=12345 -RE_CLUSTER_NAME=test -RE_USE_OSS_CLUSTER=false -RE_DB_PORT=6379 diff --git a/.github/workflows/modes/.env.enterprise_oss_cluster b/.github/workflows/modes/.env.enterprise_oss_cluster deleted file mode 100644 index 1b81f571..00000000 --- a/.github/workflows/modes/.env.enterprise_oss_cluster +++ /dev/null @@ -1,8 +0,0 @@ -REDIS_CLUSTER=127.0.0.1:6372 -NUM_REDIS_CLUSTER_NODES=3 -IS_ENTERPRISE=true -RE_USERNAME=test@test.com -RE_PASS=12345 -RE_CLUSTER_NAME=test -RE_USE_OSS_CLUSTER=true -RE_DB_PORT=6378 \ No newline at end of file diff --git a/.github/workflows/modes/.env.oss_cluster b/.github/workflows/modes/.env.oss_cluster deleted file mode 100644 index 0d2a2906..00000000 --- a/.github/workflows/modes/.env.oss_cluster +++ /dev/null @@ -1,2 +0,0 @@ -REDIS_CLUSTER=127.0.0.1:16379 -NUM_REDIS_CLUSTER_NODES=6 \ No newline at end of file diff --git a/.github/workflows/modes/.env.standalone b/.github/workflows/modes/.env.standalone deleted file mode 100644 index e0cfd098..00000000 --- a/.github/workflows/modes/.env.standalone +++ /dev/null @@ -1 +0,0 @@ -REDIS=localhost:6379 \ No newline at end of file diff --git a/tests/Doc/Bf_tutorial.cs b/tests/Doc/Bf_tutorial.cs index 6d08c2e2..01be785f 100644 --- a/tests/Doc/Bf_tutorial.cs +++ b/tests/Doc/Bf_tutorial.cs @@ -15,8 +15,7 @@ namespace Doc; // HIDE_START public class Bf_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/Bitmap_tutorial.cs b/tests/Doc/Bitmap_tutorial.cs index b6892040..104b0a7e 100644 --- a/tests/Doc/Bitmap_tutorial.cs +++ b/tests/Doc/Bitmap_tutorial.cs @@ -14,8 +14,7 @@ namespace Doc; // HIDE_START public class Bitmap_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/CmdsGenericExample.cs b/tests/Doc/CmdsGenericExample.cs index 950805bd..448c6efb 100644 --- a/tests/Doc/CmdsGenericExample.cs +++ b/tests/Doc/CmdsGenericExample.cs @@ -15,7 +15,6 @@ namespace Doc; public class CmdsGenericExample { - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.0.0")] public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/CmdsHashExample.cs b/tests/Doc/CmdsHashExample.cs index 40036e15..0efccf85 100644 --- a/tests/Doc/CmdsHashExample.cs +++ b/tests/Doc/CmdsHashExample.cs @@ -14,8 +14,7 @@ namespace Doc; // HIDE_START public class CmdsHashExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/CmdsSortedSetExamples.cs b/tests/Doc/CmdsSortedSetExamples.cs index 6ae81201..a6ef9a36 100644 --- a/tests/Doc/CmdsSortedSetExamples.cs +++ b/tests/Doc/CmdsSortedSetExamples.cs @@ -14,8 +14,7 @@ namespace Doc; // HIDE_START public class CmdsSortedSet { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/CmdsStringExample.cs b/tests/Doc/CmdsStringExample.cs index 462cacd1..8a40a30c 100644 --- a/tests/Doc/CmdsStringExample.cs +++ b/tests/Doc/CmdsStringExample.cs @@ -14,8 +14,7 @@ namespace Doc; // HIDE_START public class CmdsStringExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/Cms_tutorial.cs b/tests/Doc/Cms_tutorial.cs index ae97bf0b..4963e001 100644 --- a/tests/Doc/Cms_tutorial.cs +++ b/tests/Doc/Cms_tutorial.cs @@ -16,8 +16,7 @@ namespace Doc; // HIDE_START public class Cms_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/Cuckoo_tutorial.cs b/tests/Doc/Cuckoo_tutorial.cs index dd469cda..79a2ca56 100644 --- a/tests/Doc/Cuckoo_tutorial.cs +++ b/tests/Doc/Cuckoo_tutorial.cs @@ -15,8 +15,7 @@ namespace Doc; // HIDE_START public class Cuckoo_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/Doc.csproj b/tests/Doc/Doc.csproj index fefcd82a..bfd504b2 100644 --- a/tests/Doc/Doc.csproj +++ b/tests/Doc/Doc.csproj @@ -15,8 +15,8 @@ all - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/Doc/Geo_tutorial.cs b/tests/Doc/Geo_tutorial.cs index 94acb9cc..339a4fd9 100644 --- a/tests/Doc/Geo_tutorial.cs +++ b/tests/Doc/Geo_tutorial.cs @@ -14,8 +14,7 @@ namespace Doc; // HIDE_START public class Geo_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/HashExample.cs b/tests/Doc/HashExample.cs index 10c108cd..058eb7c7 100644 --- a/tests/Doc/HashExample.cs +++ b/tests/Doc/HashExample.cs @@ -10,7 +10,7 @@ namespace Doc; //REMOVE_END public class HashExample { - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/Hll_tutorial.cs b/tests/Doc/Hll_tutorial.cs index cf7a1ed5..75aceb4c 100644 --- a/tests/Doc/Hll_tutorial.cs +++ b/tests/Doc/Hll_tutorial.cs @@ -14,8 +14,7 @@ namespace Doc; // HIDE_START public class Hll_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/HomeJsonExample.cs b/tests/Doc/HomeJsonExample.cs index b404469d..21b39c2d 100644 --- a/tests/Doc/HomeJsonExample.cs +++ b/tests/Doc/HomeJsonExample.cs @@ -18,8 +18,7 @@ namespace Doc; // HIDE_START public class HomeJsonExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { // STEP_START connect diff --git a/tests/Doc/Json_tutorial.cs b/tests/Doc/Json_tutorial.cs index 1d5f797a..d17d3eb0 100644 --- a/tests/Doc/Json_tutorial.cs +++ b/tests/Doc/Json_tutorial.cs @@ -16,8 +16,7 @@ namespace Doc; // HIDE_START public class Json_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/ListTutorial.cs b/tests/Doc/ListTutorial.cs index 3c362edb..79ee0135 100644 --- a/tests/Doc/ListTutorial.cs +++ b/tests/Doc/ListTutorial.cs @@ -13,9 +13,6 @@ namespace Doc; //REMOVE_END public class ListExample { - //REMOVE_START - [SkipIfRedis(Is.OSSCluster)] - //REMOVE_END public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/QueryAggExample.cs b/tests/Doc/QueryAggExample.cs index ec5f696d..e59a677d 100644 --- a/tests/Doc/QueryAggExample.cs +++ b/tests/Doc/QueryAggExample.cs @@ -18,8 +18,7 @@ namespace Doc; // HIDE_START public class QueryAggExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/QueryEmExample.cs b/tests/Doc/QueryEmExample.cs index 590a212d..3fb57a95 100644 --- a/tests/Doc/QueryEmExample.cs +++ b/tests/Doc/QueryEmExample.cs @@ -17,8 +17,7 @@ namespace Doc; // HIDE_START public class QueryEmExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/QueryFtExample.cs b/tests/Doc/QueryFtExample.cs index bc7f544b..72ce588e 100644 --- a/tests/Doc/QueryFtExample.cs +++ b/tests/Doc/QueryFtExample.cs @@ -17,8 +17,7 @@ namespace Doc; // HIDE_START public class QueryFtExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/QueryRangeExample.cs b/tests/Doc/QueryRangeExample.cs index 44755930..3666184c 100644 --- a/tests/Doc/QueryRangeExample.cs +++ b/tests/Doc/QueryRangeExample.cs @@ -17,8 +17,7 @@ namespace Doc; // HIDE_START public class QueryRangeExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/SearchQuickstartExample.cs b/tests/Doc/SearchQuickstartExample.cs index c7a1f5b9..f607dc30 100644 --- a/tests/Doc/SearchQuickstartExample.cs +++ b/tests/Doc/SearchQuickstartExample.cs @@ -13,7 +13,7 @@ namespace Doc; // REMOVE_END public class SearchQuickstartExample { - [SkipIfRedis(Is.OSSCluster)] + public void run() { // STEP_START connect diff --git a/tests/Doc/SetGetExample.cs b/tests/Doc/SetGetExample.cs index 3d9af1e2..b0b2f2b1 100644 --- a/tests/Doc/SetGetExample.cs +++ b/tests/Doc/SetGetExample.cs @@ -10,8 +10,7 @@ namespace Doc; //REMOVE_END public class SetGetExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/SetsTutorial.cs b/tests/Doc/SetsTutorial.cs index 916b9f0b..9e92b9ee 100644 --- a/tests/Doc/SetsTutorial.cs +++ b/tests/Doc/SetsTutorial.cs @@ -15,8 +15,7 @@ namespace Doc; // HIDE_START public class SetsExample { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/SortedSetExample.cs b/tests/Doc/SortedSetExample.cs index d7771d58..5dce4136 100644 --- a/tests/Doc/SortedSetExample.cs +++ b/tests/Doc/SortedSetExample.cs @@ -11,9 +11,7 @@ namespace Doc; //REMOVE_END public class SortedSetExample { - //REMOVE_START - [SkipIfRedis(Is.OSSCluster)] - //REMOVE_END + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/StreamTutorial.cs b/tests/Doc/StreamTutorial.cs index d1bf89f8..f43f8192 100644 --- a/tests/Doc/StreamTutorial.cs +++ b/tests/Doc/StreamTutorial.cs @@ -15,8 +15,7 @@ namespace Doc; // HIDE_START public class StreamTutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/StringSnippets.cs b/tests/Doc/StringSnippets.cs index c7f3bade..d2f8ea24 100644 --- a/tests/Doc/StringSnippets.cs +++ b/tests/Doc/StringSnippets.cs @@ -11,9 +11,6 @@ namespace Doc; //REMOVE_END public class StringSnippets { - //REMOVE_START - [SkipIfRedis(Is.OSSCluster)] - //REMOVE_END public void run() { var redis = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/Tdigest_tutorial.cs b/tests/Doc/Tdigest_tutorial.cs index b56e237f..99a08839 100644 --- a/tests/Doc/Tdigest_tutorial.cs +++ b/tests/Doc/Tdigest_tutorial.cs @@ -15,8 +15,7 @@ namespace Doc; // HIDE_START public class Tdigest_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/Doc/Topk_tutorial.cs b/tests/Doc/Topk_tutorial.cs index ce583cf2..b9fba044 100644 --- a/tests/Doc/Topk_tutorial.cs +++ b/tests/Doc/Topk_tutorial.cs @@ -15,8 +15,7 @@ namespace Doc; // HIDE_START public class Topk_tutorial { - - [SkipIfRedis(Is.OSSCluster)] + public void run() { var muxer = ConnectionMultiplexer.Connect("localhost:6379"); diff --git a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs index e51aa449..0cd3842c 100644 --- a/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs +++ b/tests/NRedisStack.Tests/AbstractNRedisStackTest.cs @@ -1,14 +1,42 @@ using NRedisStack.DataTypes; using System.Runtime.CompilerServices; +using StackExchange.Redis; using Xunit; namespace NRedisStack.Tests; -public abstract class AbstractNRedisStackTest : IClassFixture, IAsyncLifetime +public abstract class AbstractNRedisStackTest : IClassFixture, IAsyncLifetime { - protected internal RedisFixture redisFixture; + protected internal EndpointsFixture EndpointsFixture; - protected internal AbstractNRedisStackTest(RedisFixture redisFixture) => this.redisFixture = redisFixture; + protected readonly ConfigurationOptions DefaultConnectionConfig = new() + { + AsyncTimeout = 10000, + SyncTimeout = 10000 + }; + + protected internal AbstractNRedisStackTest(EndpointsFixture endpointsFixture) + { + this.EndpointsFixture = endpointsFixture; + } + + protected ConnectionMultiplexer GetConnection(string endpointId = EndpointsFixture.Env.Standalone) => EndpointsFixture.GetConnectionById(this.DefaultConnectionConfig, endpointId); + + protected ConnectionMultiplexer GetConnection(ConfigurationOptions configurationOptions, string endpointId = EndpointsFixture.Env.Standalone) => EndpointsFixture.GetConnectionById(configurationOptions, endpointId); + + protected IDatabase GetDatabase(string endpointId = EndpointsFixture.Env.Standalone) + { + var redis = GetConnection(endpointId); + IDatabase db = redis.GetDatabase(); + return db; + } + + protected IDatabase GetCleanDatabase(string endpointId = EndpointsFixture.Env.Standalone) + { + IDatabase db = GetDatabase(endpointId); + db.Execute("FLUSHALL"); + return db; + } private List keyNames = new List(); @@ -44,13 +72,13 @@ protected internal static List ReverseData(List (RedisKey)i).ToArray()); - await redis.ExecuteBroadcastAsync("FLUSHALL"); + //await redis.ExecuteBroadcastAsync("FLUSHALL"); } } \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Bloom/BloomTests.cs b/tests/NRedisStack.Tests/Bloom/BloomTests.cs index 2198f03b..6e2fa46c 100644 --- a/tests/NRedisStack.Tests/Bloom/BloomTests.cs +++ b/tests/NRedisStack.Tests/Bloom/BloomTests.cs @@ -4,19 +4,18 @@ namespace NRedisStack.Tests.Bloom; -public class BloomTests : AbstractNRedisStackTest, IDisposable +public class BloomTests(EndpointsFixture endpointsFixture) + : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "BLOOM_TESTS"; - public BloomTests(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] - public void TestReserveBasic() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestReserveBasic(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); - bf.Reserve(key, 0.001, 100L); Assert.True((bf.Add(key, "item1"))); @@ -24,11 +23,11 @@ public void TestReserveBasic() Assert.False(bf.Exists(key, "item2")); } - [Fact] - public async Task TestReserveBasicAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestReserveBasicAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); await bf.ReserveAsync(key, 0.001, 100L); @@ -38,58 +37,55 @@ public async Task TestReserveBasicAsync() Assert.False(await bf.ExistsAsync(key, "item2")); } - [Fact] - public void TestAddWhenExist() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAddWhenExist(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); Assert.True((bf.Add(key, "item1"))); // first time Assert.False(bf.Add(key, "item1")); // second time } - [Fact] - public async Task TestAddWhenExistAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAddWhenExistAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); - Assert.True(await bf.AddAsync(key, "item1")); // first time Assert.False(await bf.AddAsync(key, "item1")); // second time } - [Fact] - public void TestAddExists() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAddExists(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); - bf.Add(key, "item1"); Assert.True(bf.Exists(key, "item1")); } - [Fact] - public async Task TestAddExistsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAddExistsAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); - await bf.AddAsync(key, "item1"); Assert.True(await bf.ExistsAsync(key, "item1")); } - [Fact] - public void TestAddExistsMulti() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAddExistsMulti(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); var items = new RedisValue[] { "foo", "bar", "baz" }; var items2 = new RedisValue[] { "newElement", "bar", "baz" }; @@ -101,11 +97,11 @@ public void TestAddExistsMulti() Assert.Equal(new bool[] { true, false, false }, result); } - [Fact] - public async Task TestAddExistsMultiAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAddExistsMultiAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); var items = new RedisValue[] { "foo", "bar", "baz" }; var items2 = new RedisValue[] { "newElement", "bar", "baz" }; @@ -117,11 +113,11 @@ public async Task TestAddExistsMultiAsync() Assert.Equal(new bool[] { true, false, false }, result); } - [Fact] - public void TestExample() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestExample(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); // Simple bloom filter using default module settings @@ -146,11 +142,11 @@ public void TestExample() bf.Add("specialBloom", "foo"); } - [Fact] - public async Task TestExampleAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestExampleAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); // Simple bloom filter using default module settings @@ -175,11 +171,11 @@ public async Task TestExampleAsync() await bf.AddAsync("specialBloom", "foo"); } - [Fact] - public void TestInsert() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInsert(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; @@ -191,11 +187,11 @@ public void TestInsert() Assert.True(bf.Exists("key", "item3")); } - [Fact] - public async Task TestInsertAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestInsertAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; @@ -207,33 +203,33 @@ public async Task TestInsertAsync() Assert.True(await bf.ExistsAsync("key", "item3")); } - [Fact] - public void TestExistsNonExist() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestExistsNonExist(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); RedisValue item = new RedisValue("item"); Assert.False(bf.Exists("NonExistKey", item)); } - [Fact] - public async Task TestExistsNonExistAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestExistsNonExistAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); RedisValue item = new RedisValue("item"); Assert.False(await bf.ExistsAsync("NonExistKey", item)); } - [Fact] - public void TestInfo() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInfo(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); bf.Add(key, "item"); @@ -245,11 +241,11 @@ public void TestInfo() Assert.Throws(() => bf.Info("notExistKey")); } - [Fact] - public async Task TestInfoAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestInfoAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); await bf.AddAsync(key, "item"); @@ -261,11 +257,11 @@ public async Task TestInfoAsync() await Assert.ThrowsAsync(() => bf.InfoAsync("notExistKey")); } - [Fact] - public void TestScanDumpAndLoadChunk() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestScanDumpAndLoadChunk(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); bf.Reserve("bloom-dump", 0.1, 10); @@ -286,11 +282,11 @@ public void TestScanDumpAndLoadChunk() Assert.True(bf.Exists("bloom-load", "a")); } - [Fact] - public async Task TestScanDumpAndLoadChunkAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestScanDumpAndLoadChunkAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); await bf.ReserveAsync("bloom-dump", 0.1, 10); @@ -311,12 +307,13 @@ public async Task TestScanDumpAndLoadChunkAsync() Assert.True(await bf.ExistsAsync("bloom-load", "a")); } - - [Fact] - public void TestModulePrefixs() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestModulePrefixs(string endpointId) { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(endpointId); + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var bf1 = db1.FT(); var bf2 = db2.FT(); @@ -324,11 +321,11 @@ public void TestModulePrefixs() Assert.NotEqual(bf1.GetHashCode(), bf2.GetHashCode()); } - [Fact] - public void TestCard() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCard(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); // return 0 if the key does not exist: @@ -343,11 +340,11 @@ public void TestCard() Assert.Throws(() => bf.Card("setKey")); } - [Fact] - public async Task TestCardAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCardAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); // return 0 if the key does not exist: @@ -362,11 +359,11 @@ public async Task TestCardAsync() await Assert.ThrowsAsync(() => bf.CardAsync("setKey")); } - [Fact] - public void TestInsertArgsError() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInsertArgsError(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var bf = db.BF(); RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; diff --git a/tests/NRedisStack.Tests/Core Commands/CoreTests.cs b/tests/NRedisStack.Tests/Core Commands/CoreTests.cs index cf330786..55a8890d 100644 --- a/tests/NRedisStack.Tests/Core Commands/CoreTests.cs +++ b/tests/NRedisStack.Tests/Core Commands/CoreTests.cs @@ -8,16 +8,14 @@ namespace NRedisStack.Tests.Core; -public class CoreTests : AbstractNRedisStackTest, IDisposable +public class CoreTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { - public CoreTests(RedisFixture redisFixture) : base(redisFixture) { } - // TODO: understand why this test fails on enterprise - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public void TestSimpleSetInfo() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSimpleSetInfo(string endpointId) { - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); db.ClientSetInfo(SetInfoAttr.LibraryName, "TestLibraryName"); db.ClientSetInfo(SetInfoAttr.LibraryVersion, "1.2.3"); @@ -26,11 +24,11 @@ public void TestSimpleSetInfo() Assert.EndsWith($"lib-name=TestLibraryName lib-ver=1.2.3\n", info); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public async Task TestSimpleSetInfoAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSimpleSetInfoAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); await db.ClientSetInfoAsync(SetInfoAttr.LibraryName, "TestLibraryName"); await db.ClientSetInfoAsync(SetInfoAttr.LibraryVersion, "1.2.3"); @@ -39,12 +37,12 @@ public async Task TestSimpleSetInfoAsync() Assert.EndsWith($"lib-name=TestLibraryName lib-ver=1.2.3\n", info); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public void TestSetInfoDefaultValue() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSetInfoDefaultValue(string endpointId) { ResetInfoDefaults(); // demonstrate first connection - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); db.Execute(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version. @@ -52,12 +50,12 @@ public void TestSetInfoDefaultValue() Assert.EndsWith($"lib-name=NRedisStack(.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public async Task TestSetInfoDefaultValueAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSetInfoDefaultValueAsync(string endpointId) { ResetInfoDefaults(); // demonstrate first connection - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); await db.ExecuteAsync(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version. @@ -65,12 +63,12 @@ public async Task TestSetInfoDefaultValueAsync() Assert.EndsWith($"lib-name=NRedisStack(.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public void TestSetInfoWithValue() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSetInfoWithValue(string endpointId) { ResetInfoDefaults(); // demonstrate first connection - var db = redisFixture.Redis.GetDatabase("MyLibraryName;v1.0.0"); - db.Execute("FLUSHALL"); + var db = GetConnection(endpointId).GetDatabase("MyLibraryName;v1.0.0"); db.Execute(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version. @@ -78,12 +76,12 @@ public void TestSetInfoWithValue() Assert.EndsWith($"NRedisStack(MyLibraryName;v1.0.0;.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public async Task TestSetInfoWithValueAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSetInfoWithValueAsync(string endpointId) { ResetInfoDefaults(); // demonstrate first connection - var db = redisFixture.Redis.GetDatabase("MyLibraryName;v1.0.0"); - db.Execute("FLUSHALL"); + var db = GetConnection(endpointId).GetDatabase("MyLibraryName;v1.0.0"); await db.ExecuteAsync(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version. @@ -91,13 +89,13 @@ public async Task TestSetInfoWithValueAsync() Assert.EndsWith($"NRedisStack(MyLibraryName;v1.0.0;.NET_v{Environment.Version}) lib-ver={GetNRedisStackVersion()}\n", info); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public void TestSetInfoNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSetInfoNull(string endpointId) { ResetInfoDefaults(); // demonstrate first connection - var db = redisFixture.Redis.GetDatabase(null); - - db.Execute("FLUSHALL"); + var db = GetConnection(endpointId).GetDatabase(null); + var infoBefore = db.Execute("CLIENT", "INFO").ToString(); db.Execute(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version. @@ -114,13 +112,13 @@ public void TestSetInfoNull() Assert.Equal(infoAfterLibNameToEnd, infoBeforeLibNameToEnd); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public async Task TestSetInfoNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSetInfoNullAsync(string endpointId) { ResetInfoDefaults(); // demonstrate first connection - var db = redisFixture.Redis.GetDatabase(null); - - db.Execute("FLUSHALL"); + var db = GetConnection(endpointId).GetDatabase(null); + var infoBefore = (await db.ExecuteAsync("CLIENT", "INFO")).ToString(); await db.ExecuteAsync(new SerializedCommand("PING")); // only the extension method of Execute (which is used for all the commands of Redis Stack) will set the library name and version. @@ -137,11 +135,11 @@ public async Task TestSetInfoNullAsync() Assert.Equal(infoAfterLibNameToEnd, infoBeforeLibNameToEnd); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBZMPop() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZMPop(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var sortedSetKey = "my-set"; @@ -169,11 +167,11 @@ public void TestBZMPop() Assert.Equal("d", resultWithDescendingOrder.Item2[0].Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public async Task TestBZMPopAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZMPopAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var sortedSetKey = "my-set"; @@ -201,11 +199,11 @@ public async Task TestBZMPopAsync() Assert.Equal("d", resultWithDescendingOrder.Item2[0].Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBZMPopNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZMPopNull(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = db.BZMPop(0.5, "my-set", MinMaxModifier.Min, null); @@ -213,11 +211,11 @@ public void TestBZMPopNull() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public async Task TestBZMPopNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZMPopNullAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = await db.BZMPopAsync(0.5, "my-set", MinMaxModifier.Min, null); @@ -225,13 +223,14 @@ public async Task TestBZMPopNullAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBZMPopMultiplexerTimeout() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZMPopMultiplexerTimeout(string endpointId) { var configurationOptions = new ConfigurationOptions(); configurationOptions.SyncTimeout = 1000; - using var redis = redisFixture.GetConnectionById(configurationOptions, "standalone"); + using var redis = GetConnection(configurationOptions, endpointId); var db = redis.GetDatabase(null); db.Execute("FLUSHALL"); @@ -240,13 +239,14 @@ public void TestBZMPopMultiplexerTimeout() Assert.Throws(() => db.BZMPop(0, "my-set", MinMaxModifier.Min)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public async Task TestBZMPopMultiplexerTimeoutAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZMPopMultiplexerTimeoutAsync(string endpointId) { var configurationOptions = new ConfigurationOptions(); configurationOptions.SyncTimeout = 1000; - await using var redis = redisFixture.GetConnectionById(configurationOptions, "standalone"); + await using var redis = GetConnection(configurationOptions, endpointId); var db = redis.GetDatabase(null); db.Execute("FLUSHALL"); @@ -255,11 +255,11 @@ public async Task TestBZMPopMultiplexerTimeoutAsync() await Assert.ThrowsAsync(async () => await db.BZMPopAsync(0, "my-set", MinMaxModifier.Min)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBZMPopMultipleSets() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZMPopMultipleSets(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.SortedSetAdd("set-one", "a", 1.5); db.SortedSetAdd("set-one", "b", 5.1); @@ -297,11 +297,11 @@ public void TestBZMPopMultipleSets() Assert.Equal("c", result.Item2[1].Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public async Task TestBZMPopMultipleSetsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZMPopMultipleSetsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.SortedSetAdd("set-one", "a", 1.5); db.SortedSetAdd("set-one", "b", 5.1); @@ -339,20 +339,20 @@ public async Task TestBZMPopMultipleSetsAsync() Assert.Equal("c", result.Item2[1].Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBZMPopNoKeysProvided() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZMPopNoKeysProvided(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); Assert.Throws(() => db.BZMPop(0, Array.Empty(), MinMaxModifier.Min)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBZMPopWithOrderEnum() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZMPopWithOrderEnum(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var sortedSetKey = "my-set-" + Guid.NewGuid(); @@ -377,11 +377,11 @@ public void TestBZMPopWithOrderEnum() Assert.Equal("b", resultWithDescendingOrder.Item2[0].Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestBZPopMin() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZPopMin(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var sortedSetKey = "my-set"; @@ -396,11 +396,11 @@ public void TestBZPopMin() Assert.Equal(1.5, result.Item2.Score); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestBZPopMinAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZPopMinAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var sortedSetKey = "my-set"; @@ -415,11 +415,11 @@ public async Task TestBZPopMinAsync() Assert.Equal(1.5, result.Item2.Score); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestBZPopMinNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZPopMinNull(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = db.BZPopMin("my-set", 0.5); @@ -427,11 +427,11 @@ public void TestBZPopMinNull() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestBZPopMinNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZPopMinNullAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = await db.BZPopMinAsync("my-set", 0.5); @@ -439,11 +439,11 @@ public async Task TestBZPopMinNullAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestBZPopMinMultipleSets() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZPopMinMultipleSets(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.SortedSetAdd("set-one", "a", 1.5); db.SortedSetAdd("set-one", "b", 5.1); @@ -462,11 +462,11 @@ public void TestBZPopMinMultipleSets() Assert.Equal("a", result.Item2.Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestBZPopMinMultipleSetsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZPopMinMultipleSetsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.SortedSetAdd("set-one", "a", 1.5); db.SortedSetAdd("set-one", "b", 5.1); @@ -485,11 +485,11 @@ public async Task TestBZPopMinMultipleSetsAsync() Assert.Equal("a", result.Item2.Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestBZPopMax() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZPopMax(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var sortedSetKey = "my-set"; @@ -504,11 +504,11 @@ public void TestBZPopMax() Assert.Equal(5.1, result.Item2.Score); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestBZPopMaxAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZPopMaxAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var sortedSetKey = "my-set"; @@ -523,11 +523,11 @@ public async Task TestBZPopMaxAsync() Assert.Equal(5.1, result.Item2.Score); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestBZPopMaxNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZPopMaxNull(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = db.BZPopMax("my-set", 0.5); @@ -535,11 +535,11 @@ public void TestBZPopMaxNull() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestBZPopMaxNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZPopMaxNullAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = await db.BZPopMaxAsync("my-set", 0.5); @@ -547,11 +547,11 @@ public async Task TestBZPopMaxNullAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestBZPopMaxMultipleSets() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBZPopMaxMultipleSets(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.SortedSetAdd("set-one", "a", 1.5); db.SortedSetAdd("set-one", "b", 5.1); @@ -570,11 +570,11 @@ public void TestBZPopMaxMultipleSets() Assert.Equal("b", result.Item2.Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestBZPopMaxMultipleSetsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBZPopMaxMultipleSetsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.SortedSetAdd("set-one", "a", 1.5); db.SortedSetAdd("set-one", "b", 5.1); @@ -593,11 +593,11 @@ public async Task TestBZPopMaxMultipleSetsAsync() Assert.Equal("b", result.Item2.Value.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBLMPop() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLMPop(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("my-list", "a"); db.ListRightPush("my-list", "b"); @@ -623,11 +623,11 @@ public void TestBLMPop() Assert.Equal("e", resultWithDescendingOrder.Item2[0].ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public async Task TestBLMPopAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBLMPopAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("my-list", "a"); db.ListRightPush("my-list", "b"); @@ -653,11 +653,11 @@ public async Task TestBLMPopAsync() Assert.Equal("e", resultWithDescendingOrder.Item2[0].ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBLMPopNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLMPopNull(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the list, and a short server timeout, which yields null. var result = db.BLMPop(0.5, "my-list", ListSide.Left); @@ -665,11 +665,11 @@ public void TestBLMPopNull() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public async Task TestBLMPopNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBLMPopNullAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the list, and a short server timeout, which yields null. var result = await db.BLMPopAsync(0.5, "my-list", ListSide.Left); @@ -677,11 +677,11 @@ public async Task TestBLMPopNullAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBLMPopMultipleLists() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLMPopMultipleLists(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -719,11 +719,11 @@ public void TestBLMPopMultipleLists() Assert.Equal("b", result.Item2[1].ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public async Task TestBLMPopMultipleListsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBLMPopMultipleListsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -761,20 +761,20 @@ public async Task TestBLMPopMultipleListsAsync() Assert.Equal("b", result.Item2[1].ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.0.0")] - public void TestBLMPopNoKeysProvided() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLMPopNoKeysProvided(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); Assert.Throws(() => db.BLMPop(0, Array.Empty(), ListSide.Left)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public void TestBLPop() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLPop(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("my-list", "a"); db.ListRightPush("my-list", "b"); @@ -786,11 +786,11 @@ public void TestBLPop() Assert.Equal("a", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public async Task TestBLPopAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBLPopAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("my-list", "a"); db.ListRightPush("my-list", "b"); @@ -802,11 +802,11 @@ public async Task TestBLPopAsync() Assert.Equal("a", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public void TestBLPopNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLPopNull(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = db.BLPop("my-set", 0.5); @@ -814,11 +814,11 @@ public void TestBLPopNull() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public async Task TestBLPopNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBLPopNullAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = await db.BLPopAsync("my-set", 0.5); @@ -826,11 +826,11 @@ public async Task TestBLPopNullAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public void TestBLPopMultipleLists() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLPopMultipleLists(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -849,11 +849,11 @@ public void TestBLPopMultipleLists() Assert.Equal("a", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public async Task TestBLPopMultipleListsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBLPopMultipleListsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -872,11 +872,11 @@ public async Task TestBLPopMultipleListsAsync() Assert.Equal("a", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public void TestBRPop() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBRPop(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("my-list", "a"); db.ListRightPush("my-list", "b"); @@ -888,11 +888,11 @@ public void TestBRPop() Assert.Equal("b", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public async Task TestBRPopAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBRPopAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("my-list", "a"); db.ListRightPush("my-list", "b"); @@ -904,11 +904,11 @@ public async Task TestBRPopAsync() Assert.Equal("b", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public void TestBRPopNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBRPopNull(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = db.BRPop("my-set", 0.5); @@ -916,11 +916,11 @@ public void TestBRPopNull() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public async Task TestBRPopNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBRPopNullAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Nothing in the set, and a short server timeout, which yields null. var result = await db.BRPopAsync("my-set", 0.5); @@ -928,11 +928,11 @@ public async Task TestBRPopNullAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public void TestBRPopMultipleLists() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBRPopMultipleLists(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -951,11 +951,11 @@ public void TestBRPopMultipleLists() Assert.Equal("b", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.0.0")] - public async Task TestBRPopMultipleListsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBRPopMultipleListsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -974,11 +974,11 @@ public async Task TestBRPopMultipleListsAsync() Assert.Equal("b", result.Item2.ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "6.2.0")] - public void TestBLMove() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "6.2.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBLMove(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -1031,11 +1031,11 @@ public void TestBLMove() Assert.Equal("c", db.ListGetByIndex("list-two", 1)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "6.2.0")] - public async Task TestBLMoveAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "6.2.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBLMoveAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -1088,11 +1088,11 @@ public async Task TestBLMoveAsync() Assert.Equal("c", db.ListGetByIndex("list-two", 1)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.2.0")] - public void TestBRPopLPush() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.2.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBRPopLPush(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -1109,11 +1109,11 @@ public void TestBRPopLPush() Assert.Equal("b", db.ListLeftPop("list-two")); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "2.2.0")] - public async Task TestBRPopLPushAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "2.2.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBRPopLPushAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.ListRightPush("list-one", "a"); db.ListRightPush("list-one", "b"); @@ -1130,11 +1130,11 @@ public async Task TestBRPopLPushAsync() Assert.Equal("b", db.ListLeftPop("list-two")); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXRead() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXRead(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.StreamAdd("my-stream", "a", 1); db.StreamAdd("my-stream", "b", 7); @@ -1162,11 +1162,11 @@ public void TestXRead() Assert.Equal(7, streamEntry.Values[0].Value); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestXReadAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestXReadAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.StreamAdd("my-stream", "a", 1); db.StreamAdd("my-stream", "b", 7); @@ -1194,11 +1194,11 @@ public async Task TestXReadAsync() Assert.Equal(7, streamEntry.Values[0].Value); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadMultipleStreams() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadMultipleStreams(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.StreamAdd("stream-one", "a", 1); db.StreamAdd("stream-one", "b", 7); @@ -1244,11 +1244,11 @@ public void TestXReadMultipleStreams() Assert.Equal("bar", result![1].Entries[0].Values[0].Value); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestXReadMultipleStreamsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestXReadMultipleStreamsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.StreamAdd("stream-one", "a", 1); db.StreamAdd("stream-one", "b", 7); @@ -1292,11 +1292,11 @@ public async Task TestXReadMultipleStreamsAsync() Assert.Equal("bar", result![1].Entries[0].Values[0].Value); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadOnlyNewMessages() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadOnlyNewMessages(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.StreamAdd("my-stream", "a", 1); @@ -1307,11 +1307,11 @@ public void TestXReadOnlyNewMessages() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestXReadOnlyNewMessagesAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestXReadOnlyNewMessagesAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); db.StreamAdd("my-stream", "a", 1); @@ -1322,31 +1322,31 @@ public async Task TestXReadOnlyNewMessagesAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadNoKeysProvided() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadNoKeysProvided(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); Assert.Throws(() => db.XRead(Array.Empty(), new RedisValue[] { StreamSpecialIds.NewMessagesId })); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadMismatchedKeysAndPositionsCountsProvided() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadMismatchedKeysAndPositionsCountsProvided(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); Assert.Throws(() => db.XRead(new RedisKey[] { "my-stream" }, new RedisValue[] { StreamSpecialIds.NewMessagesId, StreamSpecialIds.NewMessagesId })); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadGroup() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadGroup(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var groupCreationResult = db.StreamCreateConsumerGroup("my-stream", "my-group"); Assert.True(groupCreationResult); @@ -1442,11 +1442,11 @@ public void TestXReadGroup() Assert.Empty(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestXReadGroupAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestXReadGroupAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var groupCreationResult = db.StreamCreateConsumerGroup("my-stream", "my-group"); Assert.True(groupCreationResult); @@ -1542,11 +1542,11 @@ public async Task TestXReadGroupAsync() Assert.Empty(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadGroupNoAck() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadGroupNoAck(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var groupCreationResult = db.StreamCreateConsumerGroup("my-stream", "my-group"); Assert.True(groupCreationResult); @@ -1575,11 +1575,11 @@ public void TestXReadGroupNoAck() Assert.Empty(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadGroupMultipleStreams() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadGroupMultipleStreams(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var groupCreationResult = db.StreamCreateConsumerGroup("stream-one", "my-group"); Assert.True(groupCreationResult); @@ -1629,11 +1629,11 @@ public void TestXReadGroupMultipleStreams() Assert.Equal(17, result![1].Entries[0].Values[0].Value); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestXReadGroupMultipleStreamsAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestXReadGroupMultipleStreamsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var groupCreationResult = db.StreamCreateConsumerGroup("stream-one", "my-group"); Assert.True(groupCreationResult); @@ -1683,11 +1683,11 @@ public async Task TestXReadGroupMultipleStreamsAsync() Assert.Equal(17, result![1].Entries[0].Values[0].Value); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadGroupNull() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadGroupNull(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var groupCreationResult = db.StreamCreateConsumerGroup("my-stream", "my-group"); Assert.True(groupCreationResult); @@ -1699,11 +1699,11 @@ public void TestXReadGroupNull() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public async Task TestXReadGroupNullAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestXReadGroupNullAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var groupCreationResult = db.StreamCreateConsumerGroup("my-stream", "my-group"); Assert.True(groupCreationResult); @@ -1715,21 +1715,21 @@ public async Task TestXReadGroupNullAsync() Assert.Null(result); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadGroupNoKeysProvided() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadGroupNoKeysProvided(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); Assert.Throws(() => db.XReadGroup("my-group", "consumer", Array.Empty(), new RedisValue[] { StreamSpecialIds.NewMessagesId })); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "5.0.0")] - public void TestXReadGroupMismatchedKeysAndPositionsCountsProvided() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "5.0.0")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestXReadGroupMismatchedKeysAndPositionsCountsProvided(string endpointId) { - var db = redisFixture.Redis.GetDatabase(null); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); Assert.Throws(() => db.XReadGroup("my-group", "consumer", new RedisKey[] { "my-stream" }, new RedisValue[] { StreamSpecialIds.NewMessagesId, StreamSpecialIds.NewMessagesId })); diff --git a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs index 5463725d..0db4e6e3 100644 --- a/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs +++ b/tests/NRedisStack.Tests/CountMinSketch/CmsTests.cs @@ -4,17 +4,16 @@ namespace NRedisStack.Tests.CuckooFilter; -public class CmsTests : AbstractNRedisStackTest, IDisposable +public class CmsTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "CMS_TESTS"; - public CmsTests(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] - public void TestInitByDim() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInitByDim(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); cms.InitByDim(key, 16, 4); @@ -25,11 +24,11 @@ public void TestInitByDim() Assert.Equal(0, info.Count); } - [Fact] - public async Task TestInitByDimAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestInitByDimAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); await cms.InitByDimAsync(key, 16, 4); @@ -40,11 +39,11 @@ public async Task TestInitByDimAsync() Assert.Equal(0, info.Count); } - [Fact] - public void TestInitByProb() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInitByProb(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); cms.InitByProb(key, 0.01, 0.01); @@ -55,11 +54,11 @@ public void TestInitByProb() Assert.Equal(0, info.Count); } - [Fact] - public async Task TestInitByProbAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestInitByProbAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); await cms.InitByProbAsync(key, 0.01, 0.01); @@ -70,33 +69,33 @@ public async Task TestInitByProbAsync() Assert.Equal(0, info.Count); } - [Fact] - public void TestKeyAlreadyExists() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestKeyAlreadyExists(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); cms.InitByDim("dup", 16, 4); Assert.Throws(() => cms.InitByDim("dup", 8, 6)); } - [Fact] - public async Task TestKeyAlreadyExistsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestKeyAlreadyExistsAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); await cms.InitByDimAsync("dup", 16, 4); await Assert.ThrowsAsync(() => cms.InitByDimAsync("dup", 8, 6)); } - [Fact] - public void TestIncrBy() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestIncrBy(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); cms.InitByDim(key, 1000, 5); @@ -110,11 +109,11 @@ public void TestIncrBy() } - [Fact] - public async Task TestIncrByAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestIncrByAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); await cms.InitByDimAsync(key, 1000, 5); @@ -128,11 +127,11 @@ public async Task TestIncrByAsync() } - [Fact] - public void TestIncrByMultipleArgs() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestIncrByMultipleArgs(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); cms.InitByDim(key, 1000, 5); @@ -151,11 +150,11 @@ public void TestIncrByMultipleArgs() Assert.Equal(25, info.Count); } - [Fact] - public async Task TestIncrByMultipleArgsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestIncrByMultipleArgsAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); await cms.InitByDimAsync(key, 1000, 5); @@ -175,11 +174,11 @@ public async Task TestIncrByMultipleArgsAsync() } - [Fact] - public void TestQuery() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestQuery(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); cms.InitByDim(key, 1000, 5); @@ -193,11 +192,11 @@ public void TestQuery() Assert.Equal(new long[] { 10, 15 }, resp); } - [Fact] - public async Task TestQueryAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestQueryAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); await cms.InitByDimAsync(key, 1000, 5); @@ -211,11 +210,11 @@ public async Task TestQueryAsync() Assert.Equal(new long[] { 10, 15 }, resp); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMerge() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestMerge(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); cms.InitByDim("A", 1000, 5); @@ -260,11 +259,11 @@ public void TestMerge() } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMergeAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMergeAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cms = db.CMS(); await cms.InitByDimAsync("A", 1000, 5); @@ -309,11 +308,13 @@ public async Task TestMergeAsync() } - [Fact] - public void TestModulePrefixs() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestModulePrefixs(string endpointId) { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(endpointId); + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var cms1 = db1.CMS(); var cms2 = db2.CMS(); diff --git a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs index 7ac2ca3d..34626f9d 100644 --- a/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs +++ b/tests/NRedisStack.Tests/CuckooFilter/CuckooTests.cs @@ -4,16 +4,18 @@ namespace NRedisStack.Tests.CuckooFilter; -public class CuckooTests : AbstractNRedisStackTest, IDisposable +// + +public class CuckooTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "CUCKOO_TESTS"; - public CuckooTests(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] - public void TestReserveBasic() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestReserveBasic(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); + var cf = db.CF(); Assert.True(cf.Reserve(key, 100L, maxIterations: 20, expansion: 1)); Assert.Throws(() => cf.Reserve(key, 100L)); @@ -23,11 +25,11 @@ public void TestReserveBasic() Assert.False(cf.Exists(key, "item2")); } - [Fact] - public async Task TestReserveBasicAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestReserveBasicAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); Assert.True(await cf.ReserveAsync(key, 100L, maxIterations: 20, expansion: 1)); _ = Assert.ThrowsAsync(async () => await cf.ReserveAsync(key, 100L)); @@ -37,33 +39,33 @@ public async Task TestReserveBasicAsync() Assert.False(await cf.ExistsAsync(key, "item2")); } - [Fact] - public void TestAddExists() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAddExists(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); Assert.True(cf.Add(key, "item1")); Assert.True(cf.Exists(key, "item1")); } - [Fact] - public async Task TestAddExistsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAddExistsAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); Assert.True(await cf.AddAsync(key, "item1")); Assert.True(await cf.ExistsAsync(key, "item1")); } - [Fact] - public void TestAddNX() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAddNX(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); Assert.True(cf.AddNX(key, "item1")); @@ -71,11 +73,11 @@ public void TestAddNX() Assert.True(cf.Exists(key, "item1")); } - [Fact] - public async Task TestAddNXAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAddNXAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); Assert.True(await cf.AddNXAsync(key, "item1")); @@ -83,75 +85,75 @@ public async Task TestAddNXAsync() Assert.True(await cf.ExistsAsync(key, "item1")); } - [Fact] - public void TestCountFilterDoesNotExist() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCountFilterDoesNotExist(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); Assert.Equal(0, cf.Count("notExistFilter", "notExistItem")); } - [Fact] - public async Task TestCountFilterDoesNotExistAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCountFilterDoesNotExistAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); Assert.Equal(0, await cf.CountAsync("notExistFilter", "notExistItem")); } - [Fact] - public void TestCountFilterExist() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCountFilterExist(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); cf.Insert(key, new RedisValue[] { "foo" }); Assert.Equal(0, cf.Count(key, "notExistItem")); } - [Fact] - public async Task TestCountFilterExistAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCountFilterExistAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); await cf.InsertAsync(key, new RedisValue[] { "foo" }); Assert.Equal(0, await cf.CountAsync(key, "notExistItem")); } - [Fact] - public void TestCountItemExist() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCountItemExist(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); cf.Insert(key, new RedisValue[] { "foo" }); Assert.Equal(1, cf.Count(key, "foo")); } - [Fact] - public async Task TestCountItemExistAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCountItemExistAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); await cf.InsertAsync(key, new RedisValue[] { "foo" }); Assert.Equal(1, await cf.CountAsync(key, "foo")); } - [Fact] - public void TestDelete() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestDelete(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); cf.Add(key, "item"); @@ -161,11 +163,11 @@ public void TestDelete() Assert.Throws(() => cf.Del("notExistKey", "item")); } - [Fact] - public async Task TestDeleteAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestDeleteAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); await cf.AddAsync(key, "item"); @@ -175,11 +177,11 @@ public async Task TestDeleteAsync() await Assert.ThrowsAsync(() => cf.DelAsync("notExistKey", "item")); } - [Fact] - public void TestInfo() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInfo(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); cf.Add(key, "item"); @@ -198,11 +200,11 @@ public void TestInfo() Assert.Throws(() => cf.Info("notExistKey")); } - [Fact] - public async Task TestInfoAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestInfoAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); await cf.AddAsync(key, "item"); @@ -223,11 +225,11 @@ public async Task TestInfoAsync() await Assert.ThrowsAsync(() => cf.InfoAsync("notExistKey")); } - [Fact] - public void TestInsert() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInsert(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; @@ -239,11 +241,11 @@ public void TestInsert() Assert.True(cf.Exists("key", "item3")); } - [Fact] - public async Task TestInsertAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestInsertAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; @@ -255,11 +257,11 @@ public async Task TestInsertAsync() Assert.True(await cf.ExistsAsync("key", "item3")); } - [Fact] - public void TestInsertNX() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestInsertNX(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; @@ -283,11 +285,11 @@ public void TestInsertNX() Assert.Throws(() => cf.InsertNX(key, new RedisValue[] { })); } - [Fact] - public async Task TestInsertNXAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestInsertNXAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); RedisValue[] items = new RedisValue[] { "item1", "item2", "item3" }; @@ -311,33 +313,33 @@ public async Task TestInsertNXAsync() _ = Assert.ThrowsAsync(async () => await cf.InsertNXAsync(key, new RedisValue[] { })); } - [Fact] - public void TestExistsNonExist() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestExistsNonExist(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); RedisValue item = new RedisValue("item"); Assert.False(cf.Exists("NonExistKey", item)); } - [Fact] - public async Task TestExistsNonExistAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestExistsNonExistAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); RedisValue item = new RedisValue("item"); Assert.False(await cf.ExistsAsync("NonExistKey", item)); } - [Fact] - public void TestScanDumpAndLoadChunk() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestScanDumpAndLoadChunk(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); cf.Reserve("cuckoo", 100, 50); @@ -358,11 +360,11 @@ public void TestScanDumpAndLoadChunk() Assert.True(cf.Exists("cuckoo-load", "a")); } - [Fact] - public async Task TestScanDumpAndLoadChunkAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestScanDumpAndLoadChunkAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var cf = db.CF(); await cf.ReserveAsync("cuckoo", 100, 50); @@ -384,11 +386,14 @@ public async Task TestScanDumpAndLoadChunkAsync() } - [Fact] - public void TestModulePrefixs() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestModulePrefixs(string endpointId) { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(endpointId); + + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var cf1 = db1.CF(); var cf2 = db2.CF(); diff --git a/tests/NRedisStack.Tests/EndpointsFixture.cs b/tests/NRedisStack.Tests/EndpointsFixture.cs new file mode 100644 index 00000000..6761f380 --- /dev/null +++ b/tests/NRedisStack.Tests/EndpointsFixture.cs @@ -0,0 +1,98 @@ +using StackExchange.Redis; +using System.Text.Json; +using Xunit; + +namespace NRedisStack.Tests; + +public class EndpointConfig +{ + public List? endpoints { get; set; } + + public bool tls { get; set; } + + public string? password { get; set; } + + public int? bdb_id { get; set; } + + public object? raw_endpoints { get; set; } + + public ConnectionMultiplexer CreateConnection(ConfigurationOptions configurationOptions) + { + configurationOptions.EndPoints.Clear(); + + foreach (var endpoint in endpoints!) + { + configurationOptions.EndPoints.Add(endpoint); + } + + if (password != null) + { + configurationOptions.Password = password; + } + + // TODO(imalinovskiy): Add support for TLS + // TODO(imalinovskiy): Add support for Discovery/Sentinel API + + return ConnectionMultiplexer.Connect(configurationOptions); + } +} + + +public class EndpointsFixture : IDisposable +{ + public static class Env + { + public const string Standalone = "standalone"; + public const string Cluster = "cluster"; + + public static IEnumerable AllEnvironments() + { + yield return new object[] { Standalone }; + yield return new object[] { Cluster }; + // TODO(imalinovskiy): Add support for Sentinel + } + + public static IEnumerable StandaloneOnly() + { + yield return new object[] { Standalone }; + } + } + + private readonly string? redisEndpointsPath = Environment.GetEnvironmentVariable("REDIS_ENDPOINTS_CONFIG_PATH") ?? "endpoints.json"; + private Dictionary redisEndpoints = new(); + + public static readonly bool IsEnterprise = Environment.GetEnvironmentVariable("IS_ENTERPRISE") == "true"; + + public static Version RedisVersion = new Version(Environment.GetEnvironmentVariable("REDIS_VERSION") ?? "0.0.0"); + + public EndpointsFixture() + { + if (redisEndpointsPath != null && File.Exists(redisEndpointsPath)) + { + string json = File.ReadAllText(redisEndpointsPath); + var parsedEndpoints = JsonSerializer.Deserialize>(json); + + redisEndpoints = parsedEndpoints ?? throw new Exception("Failed to parse the Redis endpoints configuration."); + } + else + { + throw new FileNotFoundException("The Redis endpoints configuration file is not found."); + } + } + + public void Dispose() + { + } + + public ConnectionMultiplexer GetConnectionById(ConfigurationOptions configurationOptions, string id) + { + Skip.IfNot(redisEndpoints.ContainsKey(id), $"The connection with id '{id}' is not configured."); + + return redisEndpoints[id].CreateConnection(configurationOptions); + } + + public bool IsTargetConnectionExist(string id) + { + return redisEndpoints.ContainsKey(id); + } +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Examples/ExampleTests.cs b/tests/NRedisStack.Tests/Examples/ExampleTests.cs index fc257b98..d6b8b628 100644 --- a/tests/NRedisStack.Tests/Examples/ExampleTests.cs +++ b/tests/NRedisStack.Tests/Examples/ExampleTests.cs @@ -10,25 +10,22 @@ namespace NRedisStack.Tests; -public class ExampleTests : AbstractNRedisStackTest, IDisposable +public class ExampleTests(EndpointsFixture endpointsFixture, ITestOutputHelper testOutputHelper) + : AbstractNRedisStackTest(endpointsFixture), IDisposable { - private readonly ITestOutputHelper testOutputHelper; + private readonly ITestOutputHelper testOutputHelper = testOutputHelper; // private readonly string key = "EXAMPLES_TESTS"; - public ExampleTests(RedisFixture redisFixture, ITestOutputHelper testOutputHelper) : base(redisFixture) - { - this.testOutputHelper = testOutputHelper; - } - [SkipIfRedis(Is.OSSCluster)] - public void HSETandSearch() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void HSETandSearch(string endpointId) { // Connect to the Redis server // var redis = ConnectionMultiplexer.Connect("localhost"); // Get a reference to the database and for search commands: // var db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ft = db.FT(); // Use HSET to add a field-value pair to a hash @@ -71,14 +68,14 @@ public void HSETandSearch() Assert.Equal(0, lastNameRod.TotalResults); } - [Fact] - public async Task AsyncExample() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task AsyncExample(string endpointId) { // Connect to the Redis server // var redis = await ConnectionMultiplexer.ConnectAsync("localhost"); // var db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var json = db.JSON(); // call async version of JSON.SET/GET @@ -86,12 +83,12 @@ public async Task AsyncExample() var john = await json.GetAsync("key"); } - [Fact] - public void PipelineExample() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void PipelineExample(string endpointId) { // Pipeline can get IDatabase for pipeline - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var pipeline = new Pipeline(db); // Add JsonSet to pipeline @@ -121,11 +118,11 @@ public void PipelineExample() Assert.Equal(expected, result.ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public async Task JsonWithSearchPipeline() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task JsonWithSearchPipeline(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); //Setup pipeline connection var pipeline = new Pipeline(db); @@ -165,16 +162,16 @@ public async Task JsonWithSearchPipeline() // Assert.Equal("person:01", firstPerson?.Id); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task PipelineWithAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task PipelineWithAsync(string endpointId) { // Connect to the Redis server // var redis = ConnectionMultiplexer.Connect("localhost"); // Get a reference to the database // var db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Setup pipeline connection var pipeline = new Pipeline(db); @@ -226,8 +223,9 @@ public async Task PipelineWithAsync() Assert.Equal("temp:JLM", response[0].key); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TransactionExample() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TransactionExample(string endpointId) { // Connect to the Redis server // var redis = ConnectionMultiplexer.Connect("localhost"); @@ -235,8 +233,7 @@ public void TransactionExample() // Get a reference to the database // var db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); // Setup transaction with IDatabase var tran = new Transaction(db); @@ -271,14 +268,14 @@ public void TransactionExample() Assert.Equal("[1200]", totalAmtOfShachar.Result.ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public void TestJsonConvert() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestJsonConvert(string endpointId) { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); // IDatabase db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); ISearchCommands ft = db.FT(); IJsonCommands json = db.JSON(); @@ -565,13 +562,13 @@ public void TestRedisCloudConnection_DotnetCore3() #endif #endif - [Fact] - public void BasicJsonExamplesTest() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void BasicJsonExamplesTest(string endpointId) { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); // IDatabase db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); IJsonCommands json = db.JSON(); // Insert a simple KVP as a JSON object: @@ -820,13 +817,13 @@ public void BasicJsonExamplesTest() Assert.Equal("{\n\t\"arr1\":[\n\t\t\"val2\",\n\t\t\"val3\"\n\t]\n}", res.ToString()); } - [Fact] - public void AdvancedJsonExamplesTest() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void AdvancedJsonExamplesTest(string endpointId) { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); // IDatabase db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); IJsonCommands json = db.JSON(); json.Set("warehouse:1", "$", new @@ -966,13 +963,13 @@ public void AdvancedJsonExamplesTest() Assert.Equal(expected, res.ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public void BasicQueryOperationsTest() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void BasicQueryOperationsTest(string endpointId) { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); // IDatabase db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); IJsonCommands json = db.JSON(); ISearchCommands ft = db.FT(); @@ -1144,13 +1141,13 @@ public void BasicQueryOperationsTest() Assert.Equal(expected, res[0].ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public void AdvancedQueryOperationsTest() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void AdvancedQueryOperationsTest(string endpointId) { // ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); // IDatabase db = redis.GetDatabase(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); IJsonCommands json = db.JSON(); ISearchCommands ft = db.FT(); diff --git a/tests/NRedisStack.Tests/Graph/GraphTests.cs b/tests/NRedisStack.Tests/Graph/GraphTests.cs index 10a6e6b3..28d8e606 100644 --- a/tests/NRedisStack.Tests/Graph/GraphTests.cs +++ b/tests/NRedisStack.Tests/Graph/GraphTests.cs @@ -6,19 +6,16 @@ namespace NRedisStack.Tests.Graph; -public class GraphTests : AbstractNRedisStackTest, IDisposable +public class GraphTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { - // private readonly string key = "GRAPH_TESTS"; - public GraphTests(RedisFixture redisFixture) : base(redisFixture) { } - #region SyncTests [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestCreateNode() + public void TestCreateNode(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create a node ResultSet resultSet = graph.Query("social", "CREATE ({name:'roi',age:32})"); @@ -38,11 +35,11 @@ public void TestCreateNode() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestCreateLabeledNode() + public void TestCreateLabeledNode(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create a node with a label ResultSet resultSet = graph.Query("social", "CREATE (:human{name:'danny',age:12})"); @@ -60,11 +57,11 @@ public void TestCreateLabeledNode() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestConnectNodes() + public void TestConnectNodes(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create both source and destination nodes Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); @@ -88,11 +85,11 @@ public void TestConnectNodes() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestDeleteNodes() + public void TestDeleteNodes(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'amit',age:30})")); @@ -136,11 +133,11 @@ public void TestDeleteNodes() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestDeleteRelationship() + public void TestDeleteRelationship(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'amit',age:30})")); @@ -167,11 +164,11 @@ public void TestDeleteRelationship() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestIndex() + public void TestIndex(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create both source and destination nodes Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); @@ -195,11 +192,11 @@ public void TestIndex() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestHeader() + public void TestHeader(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); @@ -227,11 +224,11 @@ public void TestHeader() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestRecord() + public void TestRecord(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); string name = "roi"; int age = 32; @@ -353,11 +350,11 @@ public void TestRecord() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestAdditionToProcedures() + public void TestAdditionToProcedures(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); @@ -434,11 +431,11 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestEscapedQuery() + public void TestEscapedQuery(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Dictionary params1 = new Dictionary(); params1.Add("s1", "S\"'"); @@ -454,11 +451,11 @@ public void TestEscapedQuery() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestArraySupport() + public void TestArraySupport(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Node expectedANode = new Node(); @@ -555,11 +552,11 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestPath() + public void TestPath(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); List nodes = new List(3); for (int i = 0; i < 3; i++) @@ -608,11 +605,11 @@ public void TestPath() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestNullGraphEntities() + public void TestNullGraphEntities(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create two nodes connected by a single outgoing edge. Assert.NotNull(graph.Query("social", "CREATE (:L)-[:E]->(:L2)")); @@ -665,11 +662,11 @@ record = resultSet.Skip(1).First(); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void Test64BitNumber() + public void Test64BitNumber(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); long value = 1L << 40; Dictionary parameters = new Dictionary(); @@ -684,11 +681,11 @@ public void Test64BitNumber() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestCachedExecution() + public void TestCachedExecution(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); graph.Query("social", "CREATE (:N {val:1}), (:N {val:2})"); @@ -716,11 +713,11 @@ public void TestCachedExecution() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestMapDataType() + public void TestMapDataType(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Dictionary expected = new Dictionary { @@ -748,11 +745,11 @@ public void TestMapDataType() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestGeoPointLatLon() + public void TestGeoPointLatLon(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet rs = graph.Query("social", "CREATE (:restaurant" + " {location: point({latitude:30.27822306, longitude:-97.75134723})})"); @@ -763,11 +760,11 @@ public void TestGeoPointLatLon() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestGeoPointLonLat() + public void TestGeoPointLonLat(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet rs = graph.Query("social", "CREATE (:restaurant" + " {location: point({longitude:-97.75134723, latitude:30.27822306})})"); @@ -794,8 +791,9 @@ private void AssertTestGeoPoint(IGraphCommands graph) } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestPoint() + public void TestPoint(string endpointId) { var point = new Point(30.27822306, -97.75134723); @@ -807,11 +805,11 @@ public void TestPoint() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void timeoutArgument() + public void timeoutArgument(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet rs = graph.Query("social", "UNWIND range(0,100) AS x WITH x AS x WHERE x = 100 RETURN x", 1L); Assert.Single(rs); @@ -822,11 +820,11 @@ public void timeoutArgument() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestCachedExecutionReadOnly() + public void TestCachedExecutionReadOnly(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); graph.Query("social", "CREATE (:N {val:1}), (:N {val:2})"); @@ -856,11 +854,11 @@ public void TestCachedExecutionReadOnly() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestSimpleReadOnly() + public void TestSimpleReadOnly(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); graph.Query("social", "CREATE (:person{name:'filipe',age:30})"); ResultSet rsRo = graph.RO_Query("social", "MATCH (a:person) WHERE (a.name = 'filipe') RETURN a.age"); @@ -872,11 +870,11 @@ public void TestSimpleReadOnly() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestProfile() + public void TestProfile(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(graph.Query("social", "CREATE (:person{name:'amit',age:30})")); @@ -891,11 +889,11 @@ public void TestProfile() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestExplain() + public void TestExplain(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(graph.Profile("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(graph.Profile("social", "CREATE (:person{name:'amit',age:30})")); @@ -910,11 +908,11 @@ public void TestExplain() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestSlowlog() + public void TestSlowlog(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(graph.Profile("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(graph.Profile("social", "CREATE (:person{name:'amit',age:30})")); @@ -926,11 +924,11 @@ public void TestSlowlog() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestList() + public void TestList(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.Empty(graph.List()); @@ -940,11 +938,11 @@ public void TestList() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestConfig() + public void TestConfig(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); graph.Query("social", "CREATE (:person{name:'filipe',age:30})"); @@ -961,11 +959,12 @@ public void TestConfig() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestModulePrefixs() + public void TestModulePrefixs(string endpointId) { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + IDatabase db1 = GetDatabase(endpointId); + IDatabase db2 = GetDatabase(endpointId); var graph1 = db1.GRAPH(); var graph2 = db2.GRAPH(); @@ -974,11 +973,11 @@ public void TestModulePrefixs() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestCallProcedureDbLabels() + public void TestCallProcedureDbLabels(string endpointId) { - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); const string graphName = "social"; @@ -996,11 +995,11 @@ public void TestCallProcedureDbLabels() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestCallProcedureReadOnly() + public void TestCallProcedureReadOnly(string endpointId) { - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); const string graphName = "social"; @@ -1023,11 +1022,11 @@ public void TestCallProcedureReadOnly() #region AsyncTests [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestCreateNodeAsync() + public async Task TestCreateNodeAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create a node ResultSet resultSet = await graph.QueryAsync("social", "CREATE ({name:'roi',age:32})"); @@ -1047,11 +1046,11 @@ public async Task TestCreateNodeAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestCreateLabeledNodeAsync() + public async Task TestCreateLabeledNodeAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create a node with a label ResultSet resultSet = await graph.QueryAsync("social", "CREATE (:human{name:'danny',age:12})"); @@ -1069,11 +1068,11 @@ public async Task TestCreateLabeledNodeAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestConnectNodesAsync() + public async Task TestConnectNodesAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create both source and destination nodes Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); @@ -1098,11 +1097,11 @@ public async Task TestConnectNodesAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestDeleteNodesAsync() + public async Task TestDeleteNodesAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'amit',age:30})")); @@ -1146,11 +1145,11 @@ public async Task TestDeleteNodesAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestDeleteRelationshipAsync() + public async Task TestDeleteRelationshipAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'amit',age:30})")); @@ -1177,11 +1176,11 @@ public async Task TestDeleteRelationshipAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestIndexAsync() + public async Task TestIndexAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create both source and destination nodes Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); @@ -1205,11 +1204,11 @@ public async Task TestIndexAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestHeaderAsync() + public async Task TestHeaderAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); @@ -1237,11 +1236,11 @@ public async Task TestHeaderAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestRecordAsync() + public async Task TestRecordAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); string name = "roi"; int age = 32; @@ -1365,11 +1364,11 @@ await graph.QueryAsync("social", "MATCH (a:person), (b:person) WHERE (a.name = ' } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestAdditionToProceduresAsync() + public async Task TestAdditionToProceduresAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); @@ -1446,11 +1445,11 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestEscapedQueryAsync() + public async Task TestEscapedQueryAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Dictionary params1 = new Dictionary(); params1.Add("s1", "S\"'"); @@ -1466,11 +1465,11 @@ public async Task TestEscapedQueryAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestArraySupportAsync() + public async Task TestArraySupportAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Node expectedANode = new Node(); @@ -1567,11 +1566,11 @@ record = iterator.Current; } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestPathAsync() + public async Task TestPathAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); List nodes = new List(3); for (int i = 0; i < 3; i++) @@ -1620,11 +1619,11 @@ public async Task TestPathAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestNullGraphEntitiesAsync() + public async Task TestNullGraphEntitiesAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); // Create two nodes connected by a single outgoing edge. Assert.NotNull(await graph.QueryAsync("social", "CREATE (:L)-[:E]->(:L2)")); @@ -1675,11 +1674,11 @@ record = resultSet.Skip(1).First(); } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task Test64bitnumberAsync() + public async Task Test64bitnumberAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); long value = 1L << 40; Dictionary parameters = new Dictionary(); @@ -1694,11 +1693,11 @@ public async Task Test64bitnumberAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestCachedExecutionAsync() + public async Task TestCachedExecutionAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); await graph.QueryAsync("social", "CREATE (:N {val:1}), (:N {val:2})"); @@ -1726,11 +1725,11 @@ public async Task TestCachedExecutionAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestMapDataTypeAsync() + public async Task TestMapDataTypeAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Dictionary expected = new Dictionary { @@ -1759,11 +1758,11 @@ public async Task TestMapDataTypeAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestGeoPointLatLonAsync() + public async Task TestGeoPointLatLonAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet rs = await graph.QueryAsync("social", "CREATE (:restaurant" + " {location: point({latitude:30.27822306, longitude:-97.75134723})})"); @@ -1774,11 +1773,11 @@ public async Task TestGeoPointLatLonAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestGeoPointLonLatAsync() + public async Task TestGeoPointLonLatAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet rs = await graph.QueryAsync("social", "CREATE (:restaurant" + " {location: point({longitude:-97.75134723, latitude:30.27822306})})"); @@ -1804,11 +1803,11 @@ private async Task AssertTestGeoPointAsync(GraphCommands graph) } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task timeoutArgumentAsync() + public async Task timeoutArgumentAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet rs = await graph.QueryAsync("social", "UNWIND range(0,100) AS x WITH x AS x WHERE x = 100 RETURN x", 1L); Assert.Single(rs); @@ -1819,11 +1818,11 @@ public async Task timeoutArgumentAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestCachedExecutionReadOnlyAsync() + public async Task TestCachedExecutionReadOnlyAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); await graph.QueryAsync("social", "CREATE (:N {val:1}), (:N {val:2})"); @@ -1853,11 +1852,11 @@ public async Task TestCachedExecutionReadOnlyAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestSimpleReadOnlyAsync() + public async Task TestSimpleReadOnlyAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); await graph.QueryAsync("social", "CREATE (:person{name:'filipe',age:30})"); ResultSet rsRo = await graph.RO_QueryAsync("social", "MATCH (a:person) WHERE (a.name = 'filipe') RETURN a.age"); @@ -1869,11 +1868,11 @@ public async Task TestSimpleReadOnlyAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestProfileAsync() + public async Task TestProfileAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(await graph.QueryAsync("social", "CREATE (:person{name:'amit',age:30})")); @@ -1888,11 +1887,11 @@ public async Task TestProfileAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestExplainAsync() + public async Task TestExplainAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(await graph.ProfileAsync("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(await graph.ProfileAsync("social", "CREATE (:person{name:'amit',age:30})")); @@ -1907,11 +1906,11 @@ public async Task TestExplainAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestSlowlogAsync() + public async Task TestSlowlogAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.NotNull(await graph.ProfileAsync("social", "CREATE (:person{name:'roi',age:32})")); Assert.NotNull(await graph.ProfileAsync("social", "CREATE (:person{name:'amit',age:30})")); @@ -1923,11 +1922,11 @@ public async Task TestSlowlogAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestListAsync() + public async Task TestListAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); Assert.Empty(await graph.ListAsync()); @@ -1937,11 +1936,11 @@ public async Task TestListAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestConfigAsync() + public async Task TestConfigAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); await graph.QueryAsync("social", "CREATE (:person{name:'filipe',age:30})"); @@ -1958,11 +1957,11 @@ public async Task TestConfigAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestCallProcedureDbLabelsAsync() + public async Task TestCallProcedureDbLabelsAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); const string graphName = "social"; @@ -1980,11 +1979,11 @@ public async Task TestCallProcedureDbLabelsAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestCallProcedureReadOnlyAsync() + public async Task TestCallProcedureReadOnlyAsync(string endpointId) { - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); const string graphName = "social"; @@ -2003,11 +2002,11 @@ public async Task TestCallProcedureReadOnlyAsync() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestParseInfinity() + public void TestParseInfinity(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet rs = graph.Query("db", "RETURN 10^100000"); Assert.Single(rs); @@ -2018,11 +2017,11 @@ public void TestParseInfinity() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestEqualsAndToString() + public void TestEqualsAndToString(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var graph = db.GRAPH(); ResultSet resultSet1 = graph.Query("db", "RETURN 10^100000"); ResultSet resultSet2 = graph.Query("db", "RETURN 10^1000"); @@ -2096,13 +2095,14 @@ public void TestEqualsAndToString() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestPrepareQuery() + public void TestPrepareQuery(string endpointId) { const string return1Query = "RETURN 1"; const string return1QueryRecordString = "Record{values=1}"; - var graph = redisFixture.Redis.GetDatabase().GRAPH(); + var graph = GetDatabase(endpointId).GRAPH(); // handle chars var buildCommand = GraphCommandBuilder.Query("graph", return1Query, new Dictionary { { "a", (char)'c' } }); diff --git a/tests/NRedisStack.Tests/Json/JsonTests.cs b/tests/NRedisStack.Tests/Json/JsonTests.cs index 34994588..8abef4de 100644 --- a/tests/NRedisStack.Tests/Json/JsonTests.cs +++ b/tests/NRedisStack.Tests/Json/JsonTests.cs @@ -7,17 +7,14 @@ namespace NRedisStack.Tests; -public class JsonTests : AbstractNRedisStackTest, IDisposable +public class JsonTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { - // private readonly string _testName = "JSON_TESTS"; - public JsonTests(RedisFixture redisFixture) : base(redisFixture) { } - - [Fact] - public void TestSetFromFile() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestSetFromFile(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetCleanDatabase(endpointId); var commands = new JsonCommands(db); var keys = CreateKeyNames(1); @@ -40,12 +37,12 @@ public void TestSetFromFile() Assert.Throws(() => commands.SetFromFile(keys[0], "$", "notExistingFile.json")); } - [Fact] - public void TestSetFromDirectory() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestSetFromDirectory(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetCleanDatabase(endpointId); var commands = new JsonCommands(db); //creating json string: @@ -93,14 +90,13 @@ public void TestSetFromDirectory() Directory.Delete("BaseDir", true); } - [Fact] - public void TestJsonSetNotExist() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestJsonSetNotExist(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetCleanDatabase(endpointId); var commands = new JsonCommands(db); - db.Execute("FLUSHALL"); var obj = new Person { Name = "Shachar", Age = 23 }; Assert.True(commands.Set("Person:Shachar", "$", obj, When.NotExists)); @@ -108,12 +104,12 @@ public void TestJsonSetNotExist() Assert.True(commands.Set("Person:Shachar", "$", obj, When.Exists)); } - [Fact] - public async Task TestJsonSetNotExistAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestJsonSetNotExistAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommands(db); db.Execute("FLUSHALL"); @@ -126,8 +122,9 @@ public async Task TestJsonSetNotExistAsync() [Fact] public void TestModulePrefixs() { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(); + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var json1 = db1.JSON(); var json2 = db2.JSON(); @@ -135,11 +132,12 @@ public void TestModulePrefixs() Assert.NotEqual(json1.GetHashCode(), json2.GetHashCode()); } - [Fact] - public void TestResp() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestResp(string endpointId) { //arrange - var conn = redisFixture.Redis; + var conn = GetConnection(endpointId); var db = conn.GetDatabase(); var commands = new JsonCommands(db); var keys = CreateKeyNames(1); @@ -160,11 +158,12 @@ public void TestResp() conn.GetDatabase().KeyDelete(key); } - [Fact] - public async Task TestRespAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestRespAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; + var conn = GetConnection(endpointId); var db = conn.GetDatabase(); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); @@ -185,12 +184,12 @@ public async Task TestRespAsync() conn.GetDatabase().KeyDelete(key); } - [Fact] - public void TestStringAppend() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestStringAppend(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommands(db); var keys = CreateKeyNames(2); @@ -213,12 +212,12 @@ public void TestStringAppend() Assert.Equal(6, simpleKeyResult[0]); } - [Fact] - public async Task TestStringAppendAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestStringAppendAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); @@ -241,12 +240,12 @@ public async Task TestStringAppendAsync() Assert.Equal(6, simpleKeyResult[0]); } - [Fact] - public void StringLength() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void StringLength(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -266,12 +265,12 @@ public void StringLength() Assert.Equal(3, simpleResult[0]); } - [Fact] - public async Task StringLengthAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task StringLengthAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -291,12 +290,12 @@ public async Task StringLengthAsync() Assert.Equal(3, simpleResult[0]); } - [Fact] - public void Toggle() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Toggle(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -313,12 +312,12 @@ public void Toggle() Assert.False(simpleResult[0]); } - [Fact] - public async Task ToggleAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ToggleAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -335,12 +334,12 @@ public async Task ToggleAsync() Assert.False(simpleResult[0]); } - [Fact] - public void Type() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Type(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -359,12 +358,12 @@ public void Type() Assert.Equal(JsonType.BOOLEAN, result[0]); } - [Fact] - public async Task TypeAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TypeAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -383,11 +382,11 @@ public async Task TypeAsync() Assert.Equal(JsonType.BOOLEAN, result[0]); } - [Fact] - public void ArrayAppend() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ArrayAppend(string endpointId) { - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommands(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -401,11 +400,11 @@ public void ArrayAppend() Assert.Equal(2, result[0]); } - [Fact] - public async Task ArrayAppendAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ArrayAppendAsync(string endpointId) { - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(2); var key = keys[0]; @@ -419,11 +418,11 @@ public async Task ArrayAppendAsync() Assert.Equal(2, result[0]); } - [Fact] - public void ArrayIndex() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ArrayIndex(string endpointId) { - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommands(db); var keys = CreateKeyNames(1); var key = keys[0]; @@ -433,11 +432,11 @@ public void ArrayIndex() Assert.Equal(-1, res[1]); } - [Fact] - public async Task ArrayIndexAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ArrayIndexAsync(string endpointId) { - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); var key = keys[0]; @@ -447,10 +446,11 @@ public async Task ArrayIndexAsync() Assert.Equal(-1, res[1]); } - [Fact] - public void ArrayInsert() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ArrayInsert(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -464,10 +464,11 @@ public void ArrayInsert() Assert.Equal(4, result[0]); } - [Fact] - public async Task ArrayInsertAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ArrayInsertAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -481,10 +482,11 @@ public async Task ArrayInsertAsync() Assert.Equal(4, result[0]); } - [Fact] - public void ArrayLength() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ArrayLength(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -497,10 +499,11 @@ public void ArrayLength() Assert.Equal(3, result[0]); } - [Fact] - public async Task ArrayLengthAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ArrayLengthAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -513,10 +516,11 @@ public async Task ArrayLengthAsync() Assert.Equal(3, result[0]); } - [Fact] - public void ArrayPop() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ArrayPop(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -531,10 +535,11 @@ public void ArrayPop() Assert.Equal("\"Ally\"", result[0].ToString()); } - [Fact] - public async Task ArrayPopAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ArrayPopAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -549,10 +554,11 @@ public async Task ArrayPopAsync() Assert.Equal("\"Ally\"", result[0].ToString()); } - [Fact] - public void ArrayTrim() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ArrayTrim(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -565,10 +571,11 @@ public void ArrayTrim() Assert.Equal(2, result[0]); } - [Fact] - public async Task ArrayTrimAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ArrayTrimAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -581,10 +588,11 @@ public async Task ArrayTrimAsync() Assert.Equal(2, result[0]); } - [Fact] - public void Clear() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Clear(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -597,10 +605,11 @@ public void Clear() Assert.Equal(1, result); } - [Fact] - public async Task ClearAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ClearAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -613,10 +622,11 @@ public async Task ClearAsync() Assert.Equal(1, result); } - [Fact] - public void Del() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Del(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -629,10 +639,11 @@ public void Del() Assert.Equal(1, result); } - [Fact] - public async Task DelAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task DelAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -645,10 +656,11 @@ public async Task DelAsync() Assert.Equal(1, result); } - [Fact] - public void Forget() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Forget(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -661,10 +673,11 @@ public void Forget() Assert.Equal(1, result); } - [Fact] - public async Task ForgetAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ForgetAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key = keys[0]; var simpleKey = keys[1]; @@ -677,10 +690,11 @@ public async Task ForgetAsync() Assert.Equal(1, result); } - [Fact] - public void Get() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Get(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(3); var key = keys[0]; var complexKey = keys[1]; @@ -704,10 +718,11 @@ public void Get() Assert.Equal(35, people[1]!.Age); } - [Fact] - public async Task GetAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task GetAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(3); var key = keys[0]; var complexKey = keys[1]; @@ -731,10 +746,11 @@ public async Task GetAsync() Assert.Equal(35, people[1]!.Age); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public void MSet() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void MSet(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -755,10 +771,11 @@ public void MSet() Assert.Throws(() => commands.MSet(new KeyPathValue[0])); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.LessThan, "7.1.242")] - public async Task MSetAsync() + [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task MSetAsync(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -779,10 +796,11 @@ public async Task MSetAsync() } [SkipIfRedis("7.1.242")] - public void Merge() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Merge(string endpointId) { // Create a connection to Redis - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); Assert.True(commands.Set("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new { home = "123 Main Street" }, phone = "123-456-7890" } })); Assert.True(commands.Merge("test_merge", "$", new { person = new { age = 30 } })); @@ -798,10 +816,11 @@ public void Merge() } [SkipIfRedis("7.1.242")] - public async Task MergeAsync() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task MergeAsync(string endpointId) { // Create a connection to Redis - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); Assert.True(await commands.SetAsync("test_merge", "$", new { person = new { name = "John Doe", age = 25, address = new { home = "123 Main Street" }, phone = "123-456-7890" } })); Assert.True(await commands.MergeAsync("test_merge", "$", new { person = new { age = 30 } })); @@ -816,10 +835,11 @@ public async Task MergeAsync() Assert.Equal("{\"person\":{\"name\":\"John Doe\",\"phone\":\"123-456-7890\",\"address\":{\"home\":\"123 Main Street\",\"work\":\"Redis office\"}}}", (await commands.GetAsync("test_merge")).ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void MGet() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void MGet(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -831,10 +851,11 @@ public void MGet() Assert.Equal("[\"world\"]", result[1].ToString()); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task MGetAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task MGetAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(2); var key1 = keys[0]; var key2 = keys[1]; @@ -846,10 +867,11 @@ public async Task MGetAsync() Assert.Equal("[\"world\"]", result[1].ToString()); } - [Fact] - public void NumIncrby() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void NumIncrby(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { age = 33, a = new { age = 34 }, b = new { age = "cat" } }); @@ -859,10 +881,11 @@ public void NumIncrby() Assert.Null(result[2]); } - [Fact] - public async Task NumIncrbyAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task NumIncrbyAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { age = 33, a = new { age = 34 }, b = new { age = "cat" } }); @@ -872,10 +895,11 @@ public async Task NumIncrbyAsync() Assert.Null(result[2]); } - [Fact] - public void ObjectKeys() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ObjectKeys(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(3); var key = keys[0]; commands.Set(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -890,10 +914,11 @@ public void ObjectKeys() Assert.Contains("b", result[1]); } - [Fact] - public async Task ObjectKeysAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ObjectKeysAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(3); var key = keys[0]; await commands.SetAsync(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -908,10 +933,11 @@ public async Task ObjectKeysAsync() Assert.Contains("b", result[1]); } - [Fact] - public void ObjectLength() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void ObjectLength(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(3); var key = keys[0]; commands.Set(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -924,10 +950,11 @@ public void ObjectLength() } - [Fact] - public async Task ObjectLengthAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task ObjectLengthAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(3); var key = keys[0]; await commands.SetAsync(key, "$", new { a = 5, b = 10, c = "hello", d = new { a = new { a = 6, b = "hello" }, b = 7 } }); @@ -940,10 +967,11 @@ public async Task ObjectLengthAsync() } - [Fact] - public void TestMultiPathGet() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestMultiPathGet(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { a = "hello", b = new { a = "world" } }); @@ -964,10 +992,11 @@ public void TestMultiPathGet() Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world"); } - [Fact] - public async Task TestMultiPathGetAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMultiPathGetAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { a = "hello", b = new { a = "world" } }); @@ -988,10 +1017,11 @@ public async Task TestMultiPathGetAsync() Assert.True(obj["$.b"]![0]!["a"]!.ToString() == "world"); } - [Fact] - public void Memory() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void Memory(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; @@ -1002,10 +1032,11 @@ public void Memory() Assert.Equal(0, res); } - [Fact] - public async Task MemoryAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task MemoryAsync(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; @@ -1016,12 +1047,12 @@ public async Task MemoryAsync() Assert.Equal(0, res); } - [Fact] - public async Task TestSetFromFileAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSetFromFileAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); var keys = CreateKeyNames(1); @@ -1044,12 +1075,12 @@ public async Task TestSetFromFileAsync() await Assert.ThrowsAsync(async () => await commands.SetFromFileAsync(keys[0], "$", "notExistingFile.json")); } - [Fact] - public async Task TestSetFromDirectoryAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSetFromDirectoryAsync(string endpointId) { //arrange - var conn = redisFixture.Redis; - var db = conn.GetDatabase(); + var db = GetDatabase(endpointId); var commands = new JsonCommandsAsync(db); //creating json string: @@ -1119,10 +1150,11 @@ public void TestJsonCommandBuilder() Assert.Equal("JSON.GET", getBuild2.Command); } - [Fact] - public void TestGetIssue198() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestGetIssue198(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new Person() { Age = 35, Name = "Alice" }); @@ -1136,10 +1168,11 @@ public void TestGetIssue198() Assert.Null(result2); } - [Fact] - public async Task TestGetIssue198_Async() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestGetIssue198_Async(string endpointId) { - var commands = new JsonCommandsAsync(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommandsAsync(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new Person() { Age = 35, Name = "Alice" }); @@ -1153,10 +1186,11 @@ public async Task TestGetIssue198_Async() Assert.Null(result2); } - [Fact] - public void TestSetWithSerializationOptions() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestSetWithSerializationOptions(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; var jsonOptions = new JsonSerializerOptions { IncludeFields = true }; @@ -1172,10 +1206,11 @@ public void TestSetWithSerializationOptions() Assert.Equal(person.Birthday, result!.Birthday); } - [Fact] - public async Task TestSetWithSerializationOptionsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSetWithSerializationOptionsAsync(string endpointId) { - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; var jsonOptions = new JsonSerializerOptions { IncludeFields = true }; @@ -1192,11 +1227,12 @@ public async Task TestSetWithSerializationOptionsAsync() } [SkipIfRedis("7.1.242")] - public void MergeWithSerializationOptions() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void MergeWithSerializationOptions(string endpointId) { string expected = "{\"age\":23,\"birthday\":\"2023-12-31T00:00:00\",\"name\":\"Developer\"}"; - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; commands.Set(key, "$", new { age = 5, birthday = new DateTime(2000, 1, 1) }); @@ -1212,11 +1248,12 @@ public void MergeWithSerializationOptions() } [SkipIfRedis("7.1.242")] - public async Task MergeWithSerializationOptionsAsync() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task MergeWithSerializationOptionsAsync(string endpointId) { string expected = "{\"age\":23,\"birthday\":\"2023-12-31T00:00:00\",\"name\":\"Developer\"}"; - var commands = new JsonCommands(redisFixture.Redis.GetDatabase()); + var commands = new JsonCommands(GetDatabase(endpointId)); var keys = CreateKeyNames(1); var key = keys[0]; await commands.SetAsync(key, "$", new { age = 5, birthday = new DateTime(2000, 1, 1) }); diff --git a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj index cb522fcc..dac59cf1 100644 --- a/tests/NRedisStack.Tests/NRedisStack.Tests.csproj +++ b/tests/NRedisStack.Tests/NRedisStack.Tests.csproj @@ -26,12 +26,16 @@ - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + - - - + + + + @@ -44,4 +48,10 @@ + + + Always + + + diff --git a/tests/NRedisStack.Tests/PipelineTests.cs b/tests/NRedisStack.Tests/PipelineTests.cs index cf4826fc..e165ac6a 100644 --- a/tests/NRedisStack.Tests/PipelineTests.cs +++ b/tests/NRedisStack.Tests/PipelineTests.cs @@ -6,17 +6,16 @@ namespace NRedisStack.Tests; -public class PipelineTests : AbstractNRedisStackTest, IDisposable +public class PipelineTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private const string key = "PIPELINE_TESTS"; - public PipelineTests(RedisFixture redisFixture) : base(redisFixture) { } - [SkipIfRedis(Is.OSSCluster, Comparison.GreaterThanOrEqual, "7.1.242")] + [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestModulesPipeline() + public void TestModulesPipeline(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var pipeline = new Pipeline(db); _ = pipeline.Bf.ReserveAsync("bf-key", 0.001, 100); @@ -63,12 +62,12 @@ public void TestModulesPipeline() Assert.NotNull(db.TOPK().Info("topk-key")); } - [SkipIfRedis(Is.OSSCluster)] + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestModulesPipelineWithoutGraph() + public void TestModulesPipelineWithoutGraph(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var pipeline = new Pipeline(db); _ = pipeline.Bf.ReserveAsync("bf-key", 0.001, 100); @@ -111,11 +110,11 @@ public void TestModulesPipelineWithoutGraph() Assert.NotNull(db.TOPK().Info("topk-key")); } - [SkipIfRedis(Is.OSSCluster)] - public void TestBloomPipeline() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBloomPipeline(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var pipeline = new Pipeline(db); _ = pipeline.Bf.ReserveAsync(key, 0.001, 100); @@ -137,12 +136,12 @@ public void TestBloomPipeline() } } - [Fact] - public void TestJsonPipeline() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestJsonPipeline(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); + IDatabase db = GetCleanDatabase(endpointId); var pipeline = new Pipeline(db); - pipeline.Db.ExecuteAsync("FLUSHALL"); string jsonPerson = JsonSerializer.Serialize(new Person { Name = "Shachar", Age = 23 }); _ = pipeline.Json.SetAsync("key", "$", jsonPerson); diff --git a/tests/NRedisStack.Tests/RedisFixture.cs b/tests/NRedisStack.Tests/RedisFixture.cs deleted file mode 100644 index 9dfdf2eb..00000000 --- a/tests/NRedisStack.Tests/RedisFixture.cs +++ /dev/null @@ -1,129 +0,0 @@ -using StackExchange.Redis; -using System.Text.Json; - -namespace NRedisStack.Tests; - -public class EndpointConfig -{ - public List? endpoints { get; set; } - - public bool tls { get; set; } - - public string? password { get; set; } - - public int? bdb_id { get; set; } - - public object? raw_endpoints { get; set; } - - public ConnectionMultiplexer CreateConnection(ConfigurationOptions configurationOptions) - { - configurationOptions.EndPoints.Clear(); - - foreach (var endpoint in endpoints!) - { - configurationOptions.EndPoints.Add(endpoint); - } - - if (password != null) - { - configurationOptions.Password = password; - } - - // TODO(imalinovskiy): Add support for TLS - // TODO(imalinovskiy): Add support for Discovery/Sentinel API - - return ConnectionMultiplexer.Connect(configurationOptions); - } -} - - -public class RedisFixture : IDisposable -{ - // Set the environment variable to specify your own alternate host and port: - private readonly string redisStandalone = Environment.GetEnvironmentVariable("REDIS") ?? "localhost:6379"; - private readonly string? redisCluster = Environment.GetEnvironmentVariable("REDIS_CLUSTER"); - private readonly string? numRedisClusterNodesEnv = Environment.GetEnvironmentVariable("NUM_REDIS_CLUSTER_NODES"); - - private readonly string defaultEndpointId = Environment.GetEnvironmentVariable("REDIS_DEFAULT_ENDPOINT_ID") ?? "standalone"; - private readonly string? redisEndpointsPath = Environment.GetEnvironmentVariable("REDIS_ENDPOINTS_CONFIG_PATH"); - private Dictionary redisEndpoints = new(); - - - public bool isEnterprise = Environment.GetEnvironmentVariable("IS_ENTERPRISE") == "true"; - public bool isOSSCluster; - - private ConnectionMultiplexer redis; - private ConfigurationOptions defaultConfig; - - public RedisFixture() - { - defaultConfig = new ConfigurationOptions - { - AsyncTimeout = 10000, - SyncTimeout = 10000 - }; - - if (redisEndpointsPath != null && File.Exists(redisEndpointsPath)) - { - string json = File.ReadAllText(redisEndpointsPath); - var parsedEndpoints = JsonSerializer.Deserialize>(json); - - redisEndpoints = parsedEndpoints ?? throw new Exception("Failed to parse the Redis endpoints configuration."); - } - else - { - redisEndpoints.Add("standalone", - new EndpointConfig { endpoints = new List { redisStandalone } }); - - if (redisCluster != null) - { - string[] parts = redisCluster!.Split(':'); - string host = parts[0]; - int startPort = int.Parse(parts[1]); - - var endpoints = new List(); - int numRedisClusterNodes = int.Parse(numRedisClusterNodesEnv!); - for (int i = 0; i < numRedisClusterNodes; i++) - { - endpoints.Add($"{host}:{startPort + i}"); - } - - redisEndpoints.Add("cluster", - new EndpointConfig { endpoints = endpoints }); - - // Set the default endpoint to the cluster to keep the tests consistent - defaultEndpointId = "cluster"; - isOSSCluster = true; - } - } - } - - public void Dispose() - { - Redis.Close(); - } - - public ConnectionMultiplexer Redis - { - get - { - redis = redis ?? GetConnectionById(defaultConfig, defaultEndpointId); - return redis; - } - } - - public ConnectionMultiplexer GetConnectionById(ConfigurationOptions configurationOptions, string id) - { - if (!redisEndpoints.ContainsKey(id)) - { - throw new Exception($"The connection with id '{id}' is not configured."); - } - - return redisEndpoints[id].CreateConnection(configurationOptions); - } - - public bool IsTargetConnectionExist(string id) - { - return redisEndpoints.ContainsKey(id); - } -} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Search/IndexCreationTests.cs b/tests/NRedisStack.Tests/Search/IndexCreationTests.cs index c3d73122..a702142d 100644 --- a/tests/NRedisStack.Tests/Search/IndexCreationTests.cs +++ b/tests/NRedisStack.Tests/Search/IndexCreationTests.cs @@ -6,14 +6,13 @@ namespace NRedisStack.Tests.Search; -public class IndexCreationTests : AbstractNRedisStackTest, IDisposable +public class IndexCreationTests(EndpointsFixture endpointsFixture) + : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string index = "MISSING_EMPTY_INDEX"; private static readonly string INDEXMISSING = "INDEXMISSING"; private static readonly string INDEXEMPTY = "INDEXEMPTY"; - public IndexCreationTests(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] public void TestMissingEmptyFieldCommandArgs() { @@ -38,11 +37,11 @@ public void TestMissingEmptyFieldCommandArgs() Assert.Equal(expectedArgs, cmd.Args); } - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.3.240")] - public void TestMissingFields() + [SkipIfRedis(Comparison.LessThan, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestMissingFields(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); var vectorAttrs = new Dictionary() { @@ -94,11 +93,11 @@ public void TestMissingFields() Assert.Equal("hashWithMissingFields", result.Documents[0].Id); } - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.3.240")] - public void TestEmptyFields() + [SkipIfRedis(Comparison.LessThan, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestEmptyFields(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); Schema sc = new Schema() .AddTextField("text1", 1.0, emptyIndex: true) @@ -123,11 +122,11 @@ public void TestEmptyFields() } - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.3.240")] - public void TestCreateFloat16VectorField() + [SkipIfRedis(Comparison.LessThan, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestCreateFloat16VectorField(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); var schema = new Schema().AddVectorField("v", Schema.VectorField.VectorAlgo.FLAT, new Dictionary() { diff --git a/tests/NRedisStack.Tests/Search/SearchTests.cs b/tests/NRedisStack.Tests/Search/SearchTests.cs index 2ed10466..83434509 100644 --- a/tests/NRedisStack.Tests/Search/SearchTests.cs +++ b/tests/NRedisStack.Tests/Search/SearchTests.cs @@ -12,11 +12,10 @@ namespace NRedisStack.Tests.Search; -public class SearchTests : AbstractNRedisStackTest, IDisposable +public class SearchTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { // private readonly string key = "SEARCH_TESTS"; private readonly string index = "TEST_INDEX"; - public SearchTests(RedisFixture redisFixture) : base(redisFixture) { } private void AddDocument(IDatabase db, Document doc) { @@ -58,10 +57,10 @@ private void AddDocument(IDatabase db, string key, Dictionary ob } [SkipIfRedis(Is.Enterprise)] - public void TestAggregationRequestVerbatim() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAggregationRequestVerbatim(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -81,10 +80,10 @@ public void TestAggregationRequestVerbatim() } [SkipIfRedis(Is.Enterprise)] - public async Task TestAggregationRequestVerbatimAsync() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAggregationRequestVerbatimAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -103,11 +102,11 @@ public async Task TestAggregationRequestVerbatimAsync() Assert.Equal(0, res.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public void TestAggregationRequestTimeout() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAggregationRequestTimeout(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -125,11 +124,11 @@ public void TestAggregationRequestTimeout() Assert.Equal(2, res.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestAggregationRequestTimeoutAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAggregationRequestTimeoutAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -147,11 +146,11 @@ public async Task TestAggregationRequestTimeoutAsync() Assert.Equal(2, res.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public void TestAggregations() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAggregations(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, true); @@ -186,11 +185,11 @@ public void TestAggregations() Assert.Equal(10, r2.GetLong("sum")); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestAggregationsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAggregationsAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - await db.ExecuteAsync("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, true); @@ -226,11 +225,11 @@ public async Task TestAggregationsAsync() } - [SkipIfRedis(Is.OSSCluster)] - public void TestAggregationsLoad() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAggregationsLoad(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var sc = new Schema().AddTextField("t1").AddTextField("t2"); ft.Create("idx", new FTCreateParams(), sc); @@ -254,11 +253,11 @@ public void TestAggregationsLoad() Assert.Equal("world", res[0]!["t2"]); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestAggregationsLoadAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAggregationsLoadAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - await db.ExecuteAsync("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var sc = new Schema().AddTextField("t1").AddTextField("t2"); await ft.CreateAsync("idx", new FTCreateParams(), sc); @@ -284,11 +283,11 @@ public async Task TestAggregationsLoadAsync() - [SkipIfRedis(Is.OSSCluster)] - public void TestAggregationRequestParamsDialect() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAggregationRequestParamsDialect(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -315,11 +314,11 @@ public void TestAggregationRequestParamsDialect() Assert.Equal(10, r1.GetLong("sum")); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestAggregationRequestParamsDialectAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAggregationRequestParamsDialectAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -347,11 +346,11 @@ public async Task TestAggregationRequestParamsDialectAsync() Assert.Equal(10, r1.GetLong("sum")); } - [SkipIfRedis(Is.OSSCluster)] - public void TestAggregationRequestParamsWithDefaultDialect() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAggregationRequestParamsWithDefaultDialect(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -378,11 +377,11 @@ public void TestAggregationRequestParamsWithDefaultDialect() Assert.Equal(10, r1.GetLong("sum")); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestAggregationRequestParamsWithDefaultDialectAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAggregationRequestParamsWithDefaultDialectAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -412,17 +411,16 @@ public async Task TestAggregationRequestParamsWithDefaultDialectAsync() [Fact] public void TestDefaultDialectError() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); // test error on invalid dialect: Assert.Throws(() => db.FT(0)); } - [SkipIfRedis(Is.OSSCluster)] - public void TestAlias() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAlias(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("field1"); @@ -447,11 +445,11 @@ public void TestAlias() Assert.Throws(() => ft.AliasDel("ALIAS2")); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestAliasAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAliasAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("field1"); @@ -476,11 +474,11 @@ public async Task TestAliasAsync() await Assert.ThrowsAsync(async () => await ft.AliasDelAsync("ALIAS2")); } - [SkipIfRedis(Is.OSSCluster)] - public void TestApplyAndFilterAggregations() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestApplyAndFilterAggregations(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -518,11 +516,11 @@ public void TestApplyAndFilterAggregations() Assert.Equal(67.5, r2.GetDouble("avgscore"), 0); } - [SkipIfRedis(Is.OSSCluster)] - public void TestCreate() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestCreate(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var schema = new Schema().AddTextField("first").AddTextField("last").AddNumericField("age"); var parameters = FTCreateParams.CreateParams().Filter("@age>16").Prefix("student:", "pupil:"); @@ -550,11 +548,11 @@ public void TestCreate() Assert.Equal(0, res3.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestCreateAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCreateAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var schema = new Schema().AddTextField("first").AddTextField("last").AddNumericField("age"); var parameters = FTCreateParams.CreateParams().Filter("@age>16").Prefix("student:", "pupil:"); @@ -576,11 +574,11 @@ public async Task TestCreateAsync() Assert.Equal(0, res3.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public void CreateNoParams() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void CreateNoParams(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("first", 1.0).AddTextField("last", 1.0).AddNumericField("age"); @@ -604,11 +602,11 @@ public void CreateNoParams() Assert.Equal(0, res3.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public async Task CreateNoParamsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task CreateNoParamsAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("first", 1.0).AddTextField("last", 1.0).AddNumericField("age"); @@ -632,11 +630,11 @@ public async Task CreateNoParamsAsync() Assert.Equal(0, res3.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public void CreateWithFieldNames() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void CreateWithFieldNames(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given"))) .AddField(new TextField(FieldName.Of("last"))); @@ -664,11 +662,11 @@ public void CreateWithFieldNames() Assert.Equal(1, nonAttribute.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public async Task CreateWithFieldNamesAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task CreateWithFieldNamesAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddField(new TextField(FieldName.Of("first").As("given"))) .AddField(new TextField(FieldName.Of("last"))); @@ -696,11 +694,11 @@ public async Task CreateWithFieldNamesAsync() Assert.Equal(1, nonAttribute.TotalResults); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void AlterAdd() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void AlterAdd(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0); @@ -761,11 +759,11 @@ public void AlterAdd() Assert.Equal(4, info.CursorStats.Count); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task AlterAddAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task AlterAddAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0); @@ -823,11 +821,11 @@ public async Task AlterAddAsync() Assert.Equal(4, info.CursorStats.Count); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void AlterAddSortable() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void AlterAddSortable(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0, sortable: true); @@ -887,11 +885,11 @@ public void AlterAddSortable() Assert.Equal(4, info.CursorStats.Count); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task AlterAddSortableAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task AlterAddSortableAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0, sortable: true); @@ -950,11 +948,11 @@ public async Task AlterAddSortableAsync() } // TODO : fix with FT.CONFIG response change - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public void TestConfig() + [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestConfig(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Assert.True(ft.ConfigSet("TIMEOUT", "100")); Dictionary configMap = ft.ConfigGet("*"); @@ -962,11 +960,11 @@ public void TestConfig() } // TODO : fix with FT.CONFIG response change - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public async Task TestConfigAsnyc() + [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestConfigAsnyc(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Assert.True(await ft.ConfigSetAsync("TIMEOUT", "100")); Dictionary configMap = await ft.ConfigGetAsync("*"); @@ -974,11 +972,11 @@ public async Task TestConfigAsnyc() } // TODO : fix with FT.CONFIG response change - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public void configOnTimeout() + [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void configOnTimeout(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Assert.True(ft.ConfigSet("ON_TIMEOUT", "fail")); Assert.Equal("fail", ft.ConfigGet("ON_TIMEOUT")["ON_TIMEOUT"]); @@ -987,11 +985,11 @@ public void configOnTimeout() } // TODO : fix with FT.CONFIG response change - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public async Task configOnTimeoutAsync() + [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task configOnTimeoutAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Assert.True(await ft.ConfigSetAsync("ON_TIMEOUT", "fail")); Assert.Equal("fail", (await ft.ConfigGetAsync("ON_TIMEOUT"))["ON_TIMEOUT"]); @@ -1000,11 +998,11 @@ public async Task configOnTimeoutAsync() } // TODO : fix with FT.CONFIG response change - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public void TestDialectConfig() + [SkipIfRedis( Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestDialectConfig(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); // confirm default var result = ft.ConfigGet("DEFAULT_DIALECT"); @@ -1023,11 +1021,11 @@ public void TestDialectConfig() } // TODO : fix with FT.CONFIG response change - [SkipIfRedis(Is.OSSCluster, Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public async Task TestDialectConfigAsync() + [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestDialectConfigAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); // confirm default var result = await ft.ConfigGetAsync("DEFAULT_DIALECT"); @@ -1045,11 +1043,11 @@ public async Task TestDialectConfigAsync() Assert.True(ft.ConfigSet("DEFAULT_DIALECT", "1")); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestCursor() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCursor(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -1107,11 +1105,11 @@ public async Task TestCursor() catch (RedisException) { } } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestCursorAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCursorAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema(); sc.AddTextField("name", 1.0, sortable: true); @@ -1169,11 +1167,11 @@ public async Task TestCursorAsync() catch (RedisException) { } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestAggregationGroupBy() + [SkipIfRedis(Is.Enterprise)] +[MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAggregationGroupBy(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); // Creating the index definition and schema @@ -1288,11 +1286,11 @@ public void TestAggregationGroupBy() } - [SkipIfRedis(Is.OSSCluster)] - public void TestDictionary() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestDictionary(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Assert.Equal(3L, ft.DictAdd("dict", "bar", "foo", "hello world")); @@ -1307,11 +1305,11 @@ public void TestDictionary() Assert.Empty(ft.DictDump("dict")); } - [SkipIfRedis(Is.OSSCluster)] - public void TestDropIndex() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestDropIndex(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -1340,11 +1338,11 @@ public void TestDropIndex() Assert.Equal("100", db.Execute("DBSIZE").ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestDropIndexAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestDropIndexAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -1373,11 +1371,11 @@ public async Task TestDropIndexAsync() Assert.Equal("100", db.Execute("DBSIZE").ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public void dropIndexDD() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void dropIndexDD(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -1399,11 +1397,11 @@ public void dropIndexDD() Assert.Equal("0", db.Execute("DBSIZE").ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public async Task dropIndexDDAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task dropIndexDDAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("title", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -1425,11 +1423,11 @@ public async Task dropIndexDDAsync() Assert.Equal("0", db.Execute("DBSIZE").ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestDictionaryAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestDictionaryAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Assert.Equal(3L, await ft.DictAddAsync("dict", "bar", "foo", "hello world")); @@ -1445,11 +1443,11 @@ public async Task TestDictionaryAsync() } string explainQuery = "@f3:f3_val @f2:f2_val @f1:f1_val"; - [SkipIfRedis(Is.OSSCluster)] - public void TestExplain() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestExplain(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema() .AddTextField("f1", 1.0) @@ -1469,11 +1467,11 @@ public void TestExplain() } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestExplainAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestExplainAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema() .AddTextField("f1", 1.0) @@ -1493,10 +1491,10 @@ public async Task TestExplainAsync() } [SkipIfRedis(Is.Enterprise)] - public void TestExplainCli() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestExplainCli(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); Schema sc = new Schema() .AddTextField("f1", 1.0) @@ -1516,10 +1514,10 @@ public void TestExplainCli() } [SkipIfRedis(Is.Enterprise)] - public async Task TestExplainCliAsync() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestExplainCliAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); Schema sc = new Schema() .AddTextField("f1", 1.0) @@ -1538,11 +1536,11 @@ public async Task TestExplainCliAsync() Assert.False(res.Length == 0); } - [SkipIfRedis(Is.OSSCluster)] - public void TestExplainWithDefaultDialect() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestExplainWithDefaultDialect(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(1); Schema sc = new Schema() .AddTextField("f1", 1.0) @@ -1555,11 +1553,11 @@ public void TestExplainWithDefaultDialect() Assert.False(res.Length == 0); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestExplainWithDefaultDialectAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestExplainWithDefaultDialectAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(1); Schema sc = new Schema() .AddTextField("f1", 1.0) @@ -1572,11 +1570,11 @@ public async Task TestExplainWithDefaultDialectAsync() Assert.False(res.Length == 0); } - [SkipIfRedis(Is.OSSCluster)] - public void TestSynonym() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSynonym(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var sc = new Schema().AddTextField("name", 1.0).AddTextField("addr", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -1598,11 +1596,11 @@ public void TestSynonym() Assert.Equal(expected, dump); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestSynonymAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSynonymAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var sc = new Schema().AddTextField("name", 1.0).AddTextField("addr", 1.0); Assert.True(ft.Create(index, FTCreateParams.CreateParams(), sc)); @@ -1627,8 +1625,9 @@ public async Task TestSynonymAsync() [Fact] public void TestModulePrefixs() { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(); + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var ft1 = db1.FT(); var ft2 = db2.FT(); @@ -1636,11 +1635,11 @@ public void TestModulePrefixs() Assert.NotEqual(ft1.GetHashCode(), ft2.GetHashCode()); } - [SkipIfRedis(Is.OSSCluster)] - public async Task GetTagFieldSyncAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task GetTagFieldSyncAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema() .AddTextField("title", 1.0) @@ -1694,11 +1693,11 @@ public async Task GetTagFieldSyncAsync() Assert.Equal("yellow", SyncRes[i++].ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema() .AddTextField("title", 1.0) @@ -1756,8 +1755,7 @@ public async Task TestGetTagFieldWithNonDefaultSeparatorSyncAsync() [Fact] public void TestFTCreateParamsCommandBuilder() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); Schema sc = new Schema() .AddTextField("title", 1.0) @@ -1800,8 +1798,7 @@ public void TestFTCreateParamsCommandBuilder() [Fact] public void TestFTCreateParamsCommandBuilderNoStopwords() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); Schema sc = new Schema() .AddTextField("title", 1.0) @@ -1821,11 +1818,11 @@ public void TestFTCreateParamsCommandBuilderNoStopwords() Assert.Equal("FT.CREATE", builedCommand.Command.ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public void TestFilters() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestFilters(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); // Create the index with the same fields as in the original test var sc = new Schema() @@ -1871,11 +1868,11 @@ public void TestFilters() Assert.Equal("doc1", res1.Documents[0].Id); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestFiltersAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestFiltersAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); // Create the index with the same fields as in the original test var sc = new Schema() @@ -1921,7 +1918,8 @@ public async Task TestFiltersAsync() Assert.Equal("doc1", res1.Documents[0].Id); } - [SkipIfRedis(Is.OSSCluster)] + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestQueryCommandBuilder() { var testQuery = new Query("foo").HighlightFields(new Query.HighlightTags("", ""), "txt") @@ -2011,15 +2009,15 @@ public void TestQueryCommandBuilder() } Assert.Equal("FT.SEARCH", buildCommand.Command); // test that the command not throw an exception: - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("txt")); var res = ft.Search("idx", testQuery); Assert.Empty(res.Documents); } - [SkipIfRedis(Is.OSSCluster)] + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestQueryCommandBuilderReturnField() { var testQuery = new Query("foo").HighlightFields("txt") @@ -2047,20 +2045,19 @@ public void TestQueryCommandBuilderReturnField() Assert.Equal("FT.SEARCH", buildCommand.Command); // test that the command not throw an exception: - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("txt")); var res = ft.Search("idx", testQuery); Assert.Empty(res.Documents); } - [SkipIfRedis(Is.OSSCluster)] + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] public void TestQueryCommandBuilderScore() { // TODO: write better test for scores and payloads - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); db.Execute("JSON.SET", "doc:1", "$", "[{\"arr\": [1, 2, 3]}, {\"val\": \"hello\"}, {\"val\": \"world\"}]"); @@ -2075,8 +2072,7 @@ public void TestQueryCommandBuilderScore() [Fact] public void TestFieldsCommandBuilder() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); // Create the index with the same fields as in the original test var sc = new Schema() @@ -2130,11 +2126,11 @@ public void TestFieldsCommandBuilder() } } - [SkipIfRedis(Is.OSSCluster)] - public void TestLimit() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestLimit(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("t1").AddTextField("t2")); @@ -2150,11 +2146,11 @@ public void TestLimit() Assert.Equal("a", res.GetResults()[0]["t1"].ToString()); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestLimitAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestLimitAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create("idx", new FTCreateParams(), new Schema().AddTextField("t1").AddTextField("t2")); @@ -2173,8 +2169,7 @@ public async Task TestLimitAsync() [Fact] public void Test_List() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); Assert.Equal(ft._List(), new RedisResult[] { }); } @@ -2182,8 +2177,7 @@ public void Test_List() [Fact] public async Task Test_ListAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); Assert.Equal(await ft._ListAsync(), new RedisResult[] { }); } @@ -2222,11 +2216,11 @@ public void TestVectorCount_Issue70() Assert.Equal(expected.Count(), actual.Args.Length); } - [SkipIfRedis(Is.OSSCluster)] - public void VectorSimilaritySearch() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void VectorSimilaritySearch(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var json = db.JSON(); @@ -2265,11 +2259,11 @@ public void VectorSimilaritySearch() Assert.Equal("{\"vector\":[2,2,2,2]}", jsonRes![0]); } - [SkipIfRedis(Is.OSSCluster)] - public void QueryingVectorFields() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void QueryingVectorFields(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); var json = db.JSON(); @@ -2294,8 +2288,7 @@ public void QueryingVectorFields() [Fact] public async Task TestVectorFieldJson_Issue102Async() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); var json = db.JSON(); @@ -2313,11 +2306,11 @@ public async Task TestVectorFieldJson_Issue102Async() Assert.True(await ft.CreateAsync("my_index", new FTCreateParams().On(IndexDataType.JSON), schema)); } - [SkipIfRedis(Is.OSSCluster)] - public void TestQueryAddParam_DefaultDialect() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestQueryAddParam_DefaultDialect(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); var sc = new Schema().AddNumericField("numval"); @@ -2332,11 +2325,11 @@ public void TestQueryAddParam_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestQueryAddParam_DefaultDialectAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestQueryAddParam_DefaultDialectAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); var sc = new Schema().AddNumericField("numval"); @@ -2351,11 +2344,11 @@ public async Task TestQueryAddParam_DefaultDialectAsync() Assert.Equal(2, res.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public void TestQueryParamsWithParams_DefaultDialect() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestQueryParamsWithParams_DefaultDialect(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); var sc = new Schema().AddNumericField("numval"); @@ -2379,11 +2372,11 @@ public void TestQueryParamsWithParams_DefaultDialect() Assert.Equal(2, res.TotalResults); } - [SkipIfRedis(Is.OSSCluster)] - public void TestBasicSpellCheck() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestBasicSpellCheck(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("name").AddTextField("body")); @@ -2399,11 +2392,11 @@ public void TestBasicSpellCheck() Assert.Equal(2, reply["name"]["name2"]); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestBasicSpellCheckAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestBasicSpellCheckAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("name").AddTextField("body")); @@ -2419,11 +2412,11 @@ public async Task TestBasicSpellCheckAsync() Assert.Equal(2, reply["name"]["name2"]); } - [SkipIfRedis(Is.OSSCluster)] - public void TestCrossTermDictionary() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestCrossTermDictionary(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("name").AddTextField("body")); @@ -2443,11 +2436,11 @@ public void TestCrossTermDictionary() .ExcludeTerm("slang"))); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestCrossTermDictionaryAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCrossTermDictionaryAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("name").AddTextField("body")); @@ -2470,8 +2463,7 @@ public async Task TestCrossTermDictionaryAsync() [Fact] public void TestDistanceBound() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("name").AddTextField("body")); @@ -2482,8 +2474,7 @@ public void TestDistanceBound() [Fact] public async Task TestDistanceBoundAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("name").AddTextField("body")); @@ -2494,8 +2485,7 @@ public async Task TestDistanceBoundAsync() [Fact] public void TestDialectBound() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("t")); @@ -2506,8 +2496,7 @@ public void TestDialectBound() [Fact] public async Task TestDialectBoundAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.Create(index, new FTCreateParams(), new Schema().AddTextField("t")); @@ -2515,11 +2504,11 @@ public async Task TestDialectBoundAsync() await Assert.ThrowsAsync(async () => await ft.SpellCheckAsync(index, "name", new FTSpellCheckParams().Dialect(0))); } - [SkipIfRedis(Is.OSSCluster)] - public async Task TestQueryParamsWithParams_DefaultDialectAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestQueryParamsWithParams_DefaultDialectAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(2); var sc = new Schema().AddNumericField("numval"); @@ -2548,8 +2537,7 @@ public async Task TestQueryParamsWithParams_DefaultDialectAsync() [Fact] public void TestAddAndGetSuggestion() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); string suggestion = "ANOTHER_WORD"; @@ -2571,8 +2559,7 @@ public void TestAddAndGetSuggestion() [Fact] public async Task TestAddAndGetSuggestionAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); string suggestion = "ANOTHER_WORD"; @@ -2594,8 +2581,7 @@ public async Task TestAddAndGetSuggestionAsync() [Fact] public void AddSuggestionIncrAndGetSuggestionFuzzy() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); string suggestion = "TOPIC OF WORDS"; @@ -2609,8 +2595,7 @@ public void AddSuggestionIncrAndGetSuggestionFuzzy() [Fact] public async Task AddSuggestionIncrAndGetSuggestionFuzzyAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); string suggestion = "TOPIC OF WORDS"; @@ -2624,8 +2609,7 @@ public async Task AddSuggestionIncrAndGetSuggestionFuzzyAsync() [Fact] public void getSuggestionScores() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.SugAdd(key, "COUNT_ME TOO", 1); ft.SugAdd(key, "COUNT", 1); @@ -2645,8 +2629,7 @@ public void getSuggestionScores() [Fact] public async Task getSuggestionScoresAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); await ft.SugAddAsync(key, "COUNT_ME TOO", 1); await ft.SugAddAsync(key, "COUNT", 1); @@ -2666,8 +2649,7 @@ public async Task getSuggestionScoresAsync() [Fact] public void getSuggestionMax() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.SugAdd(key, "COUNT_ME TOO", 1); ft.SugAdd(key, "COUNT", 1); @@ -2681,8 +2663,7 @@ public void getSuggestionMax() [Fact] public async Task getSuggestionMaxAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); await ft.SugAddAsync(key, "COUNT_ME TOO", 1); await ft.SugAddAsync(key, "COUNT", 1); @@ -2696,8 +2677,7 @@ public async Task getSuggestionMaxAsync() [Fact] public void getSuggestionNoHit() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.SugAdd(key, "NO WORD", 0.4); @@ -2708,8 +2688,7 @@ public void getSuggestionNoHit() [Fact] public async Task getSuggestionNoHitAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); await ft.SugAddAsync(key, "NO WORD", 0.4); @@ -2720,8 +2699,7 @@ public async Task getSuggestionNoHitAsync() [Fact] public void getSuggestionLengthAndDeleteSuggestion() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); ft.SugAdd(key, "TOPIC OF WORDS", 1, increment: true); ft.SugAdd(key, "ANOTHER ENTRY", 1, increment: true); @@ -2743,8 +2721,7 @@ public void getSuggestionLengthAndDeleteSuggestion() [Fact] public async Task getSuggestionLengthAndDeleteSuggestionAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ft = db.FT(); await ft.SugAddAsync(key, "TOPIC OF WORDS", 1, increment: true); await ft.SugAddAsync(key, "ANOTHER ENTRY", 1, increment: true); @@ -2764,10 +2741,10 @@ public async Task getSuggestionLengthAndDeleteSuggestionAsync() } [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public void TestProfileSearch() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestProfileSearch(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("t1", 1.0).AddTextField("t2", 1.0); @@ -2788,10 +2765,10 @@ public void TestProfileSearch() } [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public async Task TestProfileSearchAsync() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestProfileSearchAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema().AddTextField("t1", 1.0).AddTextField("t2", 1.0); @@ -2813,10 +2790,10 @@ public async Task TestProfileSearchAsync() [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public void TestProfile() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestProfile(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams @@ -2843,10 +2820,10 @@ public void TestProfile() } [SkipIfRedis(Is.Enterprise, Comparison.GreaterThanOrEqual, "7.3.240")] - public async Task TestProfileAsync() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestProfileAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); await ft.CreateAsync(index, new Schema().AddTextField("t")); // Calling FT.CREATR without FTCreateParams @@ -2872,10 +2849,10 @@ public async Task TestProfileAsync() } [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.3.242")] - public void TestProfileIssue306() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestProfileIssue306(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); ft.Create(index, new Schema().AddTextField("t", sortable: true)); // Calling FT.CREATR without FTCreateParams @@ -2902,10 +2879,10 @@ public void TestProfileIssue306() } [SkipIfRedis(Is.Enterprise, Comparison.LessThan, "7.3.242")] - public async Task TestProfileAsyncIssue306() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestProfileAsyncIssue306(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); await ft.CreateAsync(index, new Schema().AddTextField("t", sortable: true)); // Calling FT.CREATR without FTCreateParams @@ -2942,11 +2919,11 @@ public void TestProfileCommandBuilder() Assert.Equal(new object[] { "index", "AGGREGATE", "LIMITED", "QUERY", "*" }, aggregate.Args); } - [SkipIfRedis(Is.OSSCluster)] - public void Issue175() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void Issue175(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); SearchCommands ft = db.FT(); @@ -2960,11 +2937,11 @@ public void Issue175() Assert.True(ft.Create("myIndex", ftParams, schema)); } - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.2.1")] - public void GeoShapeFilterSpherical() + [SkipIfRedis(Comparison.LessThan, "7.2.1")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void GeoShapeFilterSpherical(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); WKTReader reader = new WKTReader(); @@ -3025,11 +3002,11 @@ public void GeoShapeFilterSpherical() Assert.Equal(2, res.Documents.Count); } - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.2.1")] - public async Task GeoShapeFilterSphericalAsync() + [SkipIfRedis(Comparison.LessThan, "7.2.1")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task GeoShapeFilterSphericalAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); WKTReader reader = new WKTReader(); @@ -3090,11 +3067,11 @@ public async Task GeoShapeFilterSphericalAsync() Assert.Equal(2, res.Documents.Count); } - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.2.1")] - public void GeoShapeFilterFlat() + [SkipIfRedis(Comparison.LessThan, "7.2.1")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void GeoShapeFilterFlat(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); WKTReader reader = new WKTReader(); GeometryFactory factory = new GeometryFactory(); @@ -3136,11 +3113,11 @@ public void GeoShapeFilterFlat() Assert.Equal(2, res.Documents.Count); } - [SkipIfRedis(Is.OSSCluster, Comparison.LessThan, "7.2.1")] - public async Task GeoShapeFilterFlatAsync() + [SkipIfRedis(Comparison.LessThan, "7.2.1")] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task GeoShapeFilterFlatAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); WKTReader reader = new WKTReader(); GeometryFactory factory = new GeometryFactory(); @@ -3195,10 +3172,10 @@ public void Issue230() } [SkipIfRedis(Comparison.LessThan, "7.3.240")] - public void TestNumericInDialect4() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestNumericInDialect4(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema() @@ -3218,10 +3195,10 @@ public void TestNumericInDialect4() } [SkipIfRedis(Comparison.LessThan, "7.3.240")] - public void TestNumericOperatorsInDialect4() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestNumericOperatorsInDialect4(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema() @@ -3248,10 +3225,10 @@ public void TestNumericOperatorsInDialect4() } [SkipIfRedis(Comparison.LessThan, "7.3.240")] - public void TestNumericLogicalOperatorsInDialect4() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestNumericLogicalOperatorsInDialect4(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ft = db.FT(); Schema sc = new Schema() diff --git a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs index eae76c4d..9a3fc098 100644 --- a/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs +++ b/tests/NRedisStack.Tests/SkipIfRedisAttribute.cs @@ -1,6 +1,7 @@ using Xunit; namespace NRedisStack.Tests; + public enum Comparison { LessThan, @@ -9,24 +10,20 @@ public enum Comparison public enum Is { - Standalone, - OSSCluster, Enterprise } [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -public class SkipIfRedisAttribute : FactAttribute +public class SkipIfRedisAttribute : SkippableTheoryAttribute { private readonly string _targetVersion; private readonly Comparison _comparison; private readonly List _environments = new List(); - private static Version serverVersion = null; - public SkipIfRedisAttribute( - Is environment, - Comparison comparison = Comparison.LessThan, - string targetVersion = "0.0.0") + Is environment, + Comparison comparison = Comparison.LessThan, + string targetVersion = "0.0.0") { _environments.Add(environment); _comparison = comparison; @@ -35,10 +32,10 @@ public SkipIfRedisAttribute( // skip more than one environment: public SkipIfRedisAttribute( - Is environment1, - Is environment2, - Comparison comparison = Comparison.LessThan, - string targetVersion = "0.0.0") + Is environment1, + Is environment2, + Comparison comparison = Comparison.LessThan, + string targetVersion = "0.0.0") { _environments.Add(environment1); _environments.Add(environment2); @@ -64,62 +61,48 @@ public override string? Skip { string skipReason = ""; bool skipped = false; - using (RedisFixture redisFixture = new RedisFixture()) - { - foreach (var environment in _environments) - { - switch (environment) - { - case Is.OSSCluster: - if (redisFixture.isOSSCluster) - { - skipReason = skipReason + " Redis server is OSS cluster."; - skipped = true; - } - break; - - case Is.Standalone: - if (!redisFixture.isOSSCluster) - { - skipReason = skipReason + " Redis server is not OSS cluster."; - skipped = true; - } - break; - - case Is.Enterprise: - if (redisFixture.isEnterprise) - { - skipReason = skipReason + " Redis Enterprise environment."; - skipped = true; - } - break; - } - } - // Version check (if Is.Standalone/Is.OSSCluster is set then ) - serverVersion = serverVersion ?? redisFixture.Redis.GetServer(redisFixture.Redis.GetEndPoints()[0]).Version; - var targetVersion = new Version(_targetVersion); - int comparisonResult = serverVersion.CompareTo(targetVersion); - - switch (_comparison) + foreach (var environment in _environments) + { + switch (environment) { - case Comparison.LessThan: - if (comparisonResult < 0) - { - skipReason = skipReason + $" Redis server version ({serverVersion}) is less than {_targetVersion}."; - skipped = true; - } - break; - case Comparison.GreaterThanOrEqual: - if (comparisonResult >= 0) + case Is.Enterprise: + if (EndpointsFixture.IsEnterprise) { - skipReason = skipReason + $" Redis server version ({serverVersion}) is greater than or equal to {_targetVersion}."; + skipReason = skipReason + " Redis Enterprise environment."; skipped = true; } + break; } } + var targetVersion = new Version(_targetVersion); + int comparisonResult = EndpointsFixture.RedisVersion.CompareTo(targetVersion); + + switch (_comparison) + { + case Comparison.LessThan: + if (comparisonResult < 0) + { + skipReason = skipReason + + $" Redis server version ({EndpointsFixture.RedisVersion}) is less than {_targetVersion}."; + skipped = true; + } + + break; + case Comparison.GreaterThanOrEqual: + if (comparisonResult >= 0) + { + skipReason = skipReason + + $" Redis server version ({EndpointsFixture.RedisVersion}) is greater than or equal to {_targetVersion}."; + skipped = true; + } + + break; + } + + if (skipped) return "Test skipped, because:" + skipReason; return null; diff --git a/tests/NRedisStack.Tests/TargetEnvironmentAttribute.cs b/tests/NRedisStack.Tests/TargetEnvironmentAttribute.cs deleted file mode 100644 index 4497aef0..00000000 --- a/tests/NRedisStack.Tests/TargetEnvironmentAttribute.cs +++ /dev/null @@ -1,36 +0,0 @@ -using Xunit; - -namespace NRedisStack.Tests; -[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] -public class TargetEnvironmentAttribute : SkipIfRedisAttribute -{ - private string targetEnv; - public TargetEnvironmentAttribute(string targetEnv) : base(Comparison.LessThan, "0.0.0") - { - this.targetEnv = targetEnv; - } - - public TargetEnvironmentAttribute(string targetEnv, Is environment, Comparison comparison = Comparison.LessThan, - string targetVersion = "0.0.0") : base(environment, comparison, targetVersion) - { - this.targetEnv = targetEnv; - } - - public TargetEnvironmentAttribute(string targetEnv, Is environment1, Is environment2, Comparison comparison = Comparison.LessThan, - string targetVersion = "0.0.0") : base(environment1, environment2, comparison, targetVersion) - { - this.targetEnv = targetEnv; - } - - public override string? Skip - { - get - { - if (!new RedisFixture().IsTargetConnectionExist(targetEnv)) - { - return "Test skipped, because: target environment not found."; - } - return base.Skip; - } - } -} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs index 9e748528..e196818a 100644 --- a/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs +++ b/tests/NRedisStack.Tests/Tdigest/TdigestTests.cs @@ -4,10 +4,9 @@ namespace NRedisStack.Tests.Tdigest; -public class TdigestTests : AbstractNRedisStackTest, IDisposable +public class TdigestTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "TDIGEST_TESTS"; - public TdigestTests(RedisFixture redisFixture) : base(redisFixture) { } private void AssertMergedUnmergedNodes(ITdigestCommands tdigest, string key, int mergedNodes, int unmergedNodes) { @@ -23,11 +22,11 @@ private void AssertTotalWeight(ITdigestCommands tdigest, string key, double tota //Assert.Equal(totalWeight, 0.01); } - [Fact] - public void TestCreateSimple() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCreateSimple(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); Assert.True(tdigest.Create(key)); @@ -44,11 +43,11 @@ public void TestCreateSimple() Assert.Equal(0, info.UnmergedNodes); } - [Fact] - public async Task TestCreateSimpleAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCreateSimpleAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); Assert.True(await tdigest.CreateAsync(key)); @@ -65,11 +64,11 @@ public async Task TestCreateSimpleAsync() Assert.Equal(0, info.UnmergedNodes); } - [Fact] - public void TestCreateAndInfo() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCreateAndInfo(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); for (int i = 100; i < 1000; i += 100) @@ -82,11 +81,11 @@ public void TestCreateAndInfo() } } - [Fact] - public async Task TestCreateAndInfoAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCreateAndInfoAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); for (int i = 100; i < 1000; i += 100) @@ -99,32 +98,13 @@ public async Task TestCreateAndInfoAsync() } } - // [Fact] - // public void TestRank() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[20]; - // for (int i = 0; i < 20; i++) - // { - // tuples[i] = new(i, 1); - // } - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(-1, tdigest.Rank("t-digest", -1)[0]); - // Assert.Equal(1, tdigest.Rank("t-digest", 0)[0]); - // Assert.Equal(11, tdigest.Rank("t-digest", 10)[0]); - // Assert.Equal(new long[3] { -1, 20, 10 }, tdigest.Rank("t-digest", -20, 20, 9)); - // } - - [Fact] - public void TestRankCommands() + + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestRankCommands(string endpointId) { //final String key = "ranks"; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create(key); tdigest.Add(key, 2d, 3d, 5d); @@ -134,12 +114,12 @@ public void TestRankCommands() Assert.Equal(new double[] { 5, 3 }, tdigest.ByRevRank(key, 0, 1)); } - [Fact] - public async Task TestRankCommandsAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestRankCommandsAsync(string endpointId) { //final String key = "ranks"; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create(key); tdigest.Add(key, 2d, 3d, 5d); @@ -149,150 +129,12 @@ public async Task TestRankCommandsAsync() Assert.Equal(new double[] { 5, 3 }, await tdigest.ByRevRankAsync(key, 0, 1)); } - // [Fact] - // public async Task TestRankAsync() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[20]; - // for (int i = 0; i < 20; i++) - // { - // tuples[i] = new(i, 1); - // } - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(-1, (await tdigest.RankAsync("t-digest", -1))[0]); - // Assert.Equal(1, (await tdigest.RankAsync("t-digest", 0))[0]); - // Assert.Equal(11, (await tdigest.RankAsync("t-digest", 10))[0]); - // Assert.Equal(new long[3] { -1, 20, 10 }, await tdigest.RankAsync("t-digest", -20, 20, 9)); - // } - - // [Fact] - // public void TestRevRank() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[20]; - // for (int i = 0; i < 20; i++) - // { - // tuples[i] = new(i, 1); - // } - - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(-1, tdigest.RevRank("t-digest", 20)[0]); - // Assert.Equal(20, tdigest.RevRank("t-digest", 0)[0]); - // Assert.Equal(new long[3] { -1, 20, 10 }, tdigest.RevRank("t-digest", 21, 0, 10)); - // } - - // [Fact] - // public async Task TestRevRankAsync() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[20]; - // for (int i = 0; i < 20; i++) - // { - // tuples[i] = new(i, 1); - // } - - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(-1, (await tdigest.RevRankAsync("t-digest", 20))[0]); - // Assert.Equal(20, (await tdigest.RevRankAsync("t-digest", 0))[0]); - // Assert.Equal(new long[3] { -1, 20, 10 }, await tdigest.RevRankAsync("t-digest", 21, 0, 10)); - // } - - // [Fact] - // public void TestByRank() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[10]; - // for (int i = 1; i <= 10; i++) - // { - // tuples[i - 1] = new(i, 1); - // } - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(1, tdigest.ByRank("t-digest", 0)[0]); - // Assert.Equal(10, tdigest.ByRank("t-digest", 9)[0]); - // Assert.True(double.IsInfinity(tdigest.ByRank("t-digest", 100)[0])); - // //Assert.Throws(() => tdigest.ByRank("t-digest", -1)[0]); - // } - - // [Fact] - // public async Task TestByRankAsync() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[10]; - // for (int i = 1; i <= 10; i++) - // { - // tuples[i - 1] = new(i, 1); - // } - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(1, (await tdigest.ByRankAsync("t-digest", 0))[0]); - // Assert.Equal(10, (await tdigest.ByRankAsync("t-digest", 9))[0]); - // Assert.True(double.IsInfinity((await tdigest.ByRankAsync("t-digest", 100))[0])); - // } - - // [Fact] - // public void TestByRevRank() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[10]; - // for (int i = 1; i <= 10; i++) - // { - // tuples[i - 1] = new(i, 1); - // } - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(10, tdigest.ByRevRank("t-digest", 0)[0]); - // Assert.Equal(2, tdigest.ByRevRank("t-digest", 9)[0]); - // Assert.True(double.IsInfinity(-tdigest.ByRevRank("t-digest", 100)[0])); - // //Assert.Throws(() => tdigest.ByRank("t-digest", -1)[0]); - // } - - // [Fact] - // public async Task TestByRevRankAsync() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // db.Execute("FLUSHALL"); - // var tdigest = db.TDIGEST(); - - // Assert.True(tdigest.Create("t-digest", 500)); - // var tuples = new Tuple[10]; - // for (int i = 1; i <= 10; i++) - // { - // tuples[i - 1] = new(i, 1); - // } - // Assert.True(tdigest.Add("t-digest", tuples)); - // Assert.Equal(10, (await tdigest.ByRevRankAsync("t-digest", 0))[0]); - // Assert.Equal(2, (await tdigest.ByRevRankAsync("t-digest", 9))[0]); - // Assert.True(double.IsInfinity(-(await tdigest.ByRevRankAsync("t-digest", 100))[0])); - // } - - - [Fact] - public void TestReset() + + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestReset(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("reset", 100); @@ -310,11 +152,11 @@ public void TestReset() AssertMergedUnmergedNodes(tdigest, "reset", 0, 0); } - [Fact] - public async Task TestResetAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestResetAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); await tdigest.CreateAsync("reset", 100); @@ -333,11 +175,11 @@ public async Task TestResetAsync() AssertMergedUnmergedNodes(tdigest, "reset", 0, 0); } - [Fact] - public void TestAdd() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAdd(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("tdadd", 100); @@ -349,11 +191,11 @@ public void TestAdd() AssertMergedUnmergedNodes(tdigest, "tdadd", 0, 5); } - [Fact] - public async Task TestAddAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAddAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); await tdigest.CreateAsync("tdadd", 100); @@ -365,11 +207,11 @@ public async Task TestAddAsync() AssertMergedUnmergedNodes(tdigest, "tdadd", 0, 5); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMerge() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMerge(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("td2", 100); @@ -388,11 +230,11 @@ public void TestMerge() } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMergeAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMergeAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); await tdigest.CreateAsync("td2", 100); @@ -411,11 +253,11 @@ public async Task TestMergeAsync() AssertMergedUnmergedNodes(tdigest, "td2", 3, 2); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void MergeMultiAndParams() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void MergeMultiAndParams(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("from1", 100); tdigest.Create("from2", 200); @@ -432,11 +274,11 @@ public void MergeMultiAndParams() Assert.Equal(50, tdigest.Info("to").Compression); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task MergeMultiAndParamsAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task MergeMultiAndParamsAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("from1", 100); tdigest.Create("from2", 200); @@ -453,11 +295,11 @@ public async Task MergeMultiAndParamsAsync() Assert.Equal(50, tdigest.Info("to").Compression); } - [Fact] - public void TestCDF() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCDF(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("tdcdf", 100); @@ -475,11 +317,11 @@ public void TestCDF() tdigest.CDF("tdcdf", 25, 50, 75); // TODO: Why needed? } - [Fact] - public async Task TestCDFAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestCDFAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); await tdigest.CreateAsync("tdcdf", 100); @@ -498,11 +340,11 @@ public async Task TestCDFAsync() } - [Fact] - public void TestQuantile() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestQuantile(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("tdqnt", 100); @@ -516,11 +358,11 @@ public void TestQuantile() Assert.Equal(new double[] { 1 }, tdigest.Quantile("tdqnt", 0.5)); } - [Fact] - public async Task TestQuantileAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestQuantileAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create("tdqnt", 100); @@ -534,11 +376,11 @@ public async Task TestQuantileAsync() Assert.Equal(new double[] { 1 }, await tdigest.QuantileAsync("tdqnt", 0.5)); } - [Fact] - public void TestMinAndMax() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestMinAndMax(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create(key, 100); @@ -553,11 +395,11 @@ public void TestMinAndMax() Assert.Equal(5d, tdigest.Max(key)); } - [Fact] - public async Task TestMinAndMaxAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMinAndMaxAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); await tdigest.CreateAsync(key, 100); @@ -572,11 +414,11 @@ public async Task TestMinAndMaxAsync() Assert.Equal(5d, await tdigest.MaxAsync(key)); } - [Fact] - public void TestTrimmedMean() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestTrimmedMean(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); tdigest.Create(key, 500); @@ -593,11 +435,11 @@ public void TestTrimmedMean() Assert.Equal(14.5, tdigest.TrimmedMean(key, 0.5, 1.0)); } - [Fact] - public async Task TestTrimmedMeanAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestTrimmedMeanAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tdigest = db.TDIGEST(); await tdigest.CreateAsync(key, 500); @@ -615,11 +457,13 @@ public async Task TestTrimmedMeanAsync() } - [Fact] - public void TestModulePrefixs() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestModulePrefixs(string endpointId) { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(endpointId); + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var tdigest1 = db1.TDIGEST(); var tdigest2 = db2.TDIGEST(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs index a7f40554..b29f6773 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAdd.cs @@ -9,15 +9,14 @@ public class TestAdd : AbstractNRedisStackTest, IDisposable { private readonly string key = "ADD_TESTS"; - public TestAdd(RedisFixture redisFixture) : base(redisFixture) { } + public TestAdd(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] [Obsolete] public void TestAddNotExistingTimeSeries() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; @@ -31,8 +30,7 @@ public void TestAddNotExistingTimeSeries() [Obsolete] public void TestAddExistingTimeSeries() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); @@ -47,8 +45,7 @@ public void TestAddExistingTimeSeries() [Obsolete] public void TestAddStar() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Add(key, "*", 1.1); @@ -61,8 +58,7 @@ public void TestAddStar() [Obsolete] public void TestAddWithRetentionTime() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; long retentionTime = 5000; @@ -77,8 +73,7 @@ public void TestAddWithRetentionTime() [Obsolete] public void TestAddWithLabels() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; TimeSeriesLabel label = new TimeSeriesLabel("key", "value"); @@ -94,8 +89,7 @@ public void TestAddWithLabels() [Obsolete] public void TestAddWithUncompressed() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); TimeStamp now = DateTime.UtcNow; @@ -109,8 +103,7 @@ public void TestAddWithUncompressed() [Obsolete] public void TestAddWithChunkSize() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; Assert.Equal(now, ts.Add(key, now, 1.1, chunkSizeBytes: 128)); @@ -123,8 +116,7 @@ public void TestAddWithChunkSize() [Fact] public void TestAddWithDuplicatePolicyBlock() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; Assert.Equal(now, ts.Add(key, now, 1.1)); @@ -134,8 +126,7 @@ public void TestAddWithDuplicatePolicyBlock() [Fact] public void TestAddWithDuplicatePolicyMin() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; Assert.Equal(now, ts.Add(key, now, 1.1)); @@ -151,8 +142,7 @@ public void TestAddWithDuplicatePolicyMin() [Fact] public void TestAddWithDuplicatePolicyMax() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; Assert.Equal(now, ts.Add(key, now, 1.1)); @@ -168,8 +158,7 @@ public void TestAddWithDuplicatePolicyMax() [Fact] public void TestAddWithDuplicatePolicySum() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; Assert.Equal(now, ts.Add(key, now, 1.1)); @@ -180,8 +169,7 @@ public void TestAddWithDuplicatePolicySum() [Fact] public void TestAddWithDuplicatePolicyFirst() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; Assert.Equal(now, ts.Add(key, now, 1.1)); @@ -192,8 +180,7 @@ public void TestAddWithDuplicatePolicyFirst() [Fact] public void TestAddWithDuplicatePolicyLast() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp now = DateTime.UtcNow; Assert.Equal(now, ts.Add(key, now, 1.1)); @@ -207,8 +194,7 @@ public void TestOldAdd() TimeStamp old_dt = DateTime.UtcNow; Thread.Sleep(1000); TimeStamp new_dt = DateTime.UtcNow; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); ts.Add(key, new_dt, 1.1); @@ -221,8 +207,7 @@ public void TestOldAdd() public void TestWrongParameters() { double value = 1.1; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var ex = Assert.Throws(() => ts.Add(key, "+", value)); Assert.Equal("ERR TSDB: invalid timestamp", ex.Message); @@ -231,10 +216,10 @@ public void TestWrongParameters() } [SkipIfRedis(Comparison.LessThan, "7.4.0")] - public void TestAddAndIgnoreValues() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAddAndIgnoreValues(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var parameters = new TsAddParamsBuilder().AddTimestamp(101).AddValue(102).AddIgnoreValues(15, 16).build(); ts.Add(key, parameters); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs index 7e641ab3..f8a075b6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAddAsync.cs @@ -8,15 +8,14 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestAddAsync : AbstractNRedisStackTest { - public TestAddAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestAddAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] [Obsolete] public async Task TestAddNotExistingTimeSeries() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1)); @@ -31,8 +30,7 @@ public async Task TestAddNotExistingTimeSeries() public async Task TestAddExistingTimeSeries() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); await ts.CreateAsync(key); TimeStamp timeStamp = DateTime.UtcNow; @@ -48,8 +46,7 @@ public async Task TestAddExistingTimeSeries() public async Task TestAddStar() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); await ts.AddAsync(key, "*", 1.1); var info = await ts.InfoAsync(key); @@ -62,8 +59,7 @@ public async Task TestAddStar() public async Task TestAddWithRetentionTime() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; long retentionTime = 5000; @@ -80,8 +76,7 @@ public async Task TestAddWithRetentionTime() public async Task TestAddWithLabels() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; var label = new TimeSeriesLabel("key", "value"); @@ -99,8 +94,7 @@ public async Task TestAddWithLabels() public async Task TestAddWithChunkSize() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1, chunkSizeBytes: 128)); @@ -115,8 +109,7 @@ public async Task TestAddWithChunkSize() public async Task TestAddWithUncompressed() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); await ts.CreateAsync(key); TimeStamp timeStamp = DateTime.UtcNow; @@ -131,8 +124,7 @@ public async Task TestAddWithUncompressed() public async Task TestAddWithDuplicatePolicyBlock() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1)); @@ -143,8 +135,7 @@ public async Task TestAddWithDuplicatePolicyBlock() public async Task TestAddWithDuplicatePolicyMin() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1)); @@ -164,8 +155,7 @@ public async Task TestAddWithDuplicatePolicyMin() public async Task TestAddWithDuplicatePolicyMax() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1)); @@ -184,8 +174,7 @@ public async Task TestAddWithDuplicatePolicyMax() public async Task TestAddWithDuplicatePolicySum() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1)); @@ -198,8 +187,7 @@ public async Task TestAddWithDuplicatePolicySum() public async Task TestAddWithDuplicatePolicyFirst() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1)); @@ -212,8 +200,7 @@ public async Task TestAddWithDuplicatePolicyFirst() public async Task TestAddWithDuplicatePolicyLast() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.AddAsync(key, timeStamp, 1.1)); @@ -226,8 +213,7 @@ public async Task TestAddWithDuplicatePolicyLast() public async Task TestOldAdd() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var dateTime = DateTime.UtcNow; TimeStamp oldTimeStamp = dateTime.AddSeconds(-1); @@ -244,8 +230,7 @@ public async Task TestWrongParameters() { var key = CreateKeyName(); var value = 1.1; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var ex = await Assert.ThrowsAsync(async () => await ts.AddAsync(key, "+", value)); Assert.Equal("ERR TSDB: invalid timestamp", ex.Message); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs index befd8b98..f67c3945 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlter.cs @@ -6,20 +6,17 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestAlter : AbstractNRedisStackTest, IDisposable + public class TestAlter(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "ALTER_TESTS"; - public TestAlter(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] [Obsolete] public void TestAlterRetentionTime() { long retentionTime = 5000; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); Assert.True(ts.Alter(key, retentionTime: retentionTime)); @@ -33,8 +30,7 @@ public void TestAlterLabels() { TimeSeriesLabel label = new TimeSeriesLabel("key", "value"); var labels = new List { label }; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); Assert.True(ts.Alter(key, labels: labels)); @@ -50,8 +46,7 @@ public void TestAlterLabels() [Obsolete] public void TestAlterPolicyAndChunk() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); Assert.True(ts.Alter(key, chunkSizeBytes: 128, duplicatePolicy: TsDuplicatePolicy.MIN)); @@ -61,10 +56,10 @@ public void TestAlterPolicyAndChunk() } [SkipIfRedis(Comparison.LessThan, "7.4.0")] - public void TestAlterAndIgnoreValues() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestAlterAndIgnoreValues(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); ts.Create(key, new TsCreateParamsBuilder().build()); var parameters = new TsAlterParamsBuilder().AddIgnoreValues(13, 14).build(); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs index ff5df550..a5199ef2 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestAlterAsync.cs @@ -7,7 +7,7 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestAlterAsync : AbstractNRedisStackTest { - public TestAlterAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestAlterAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] [Obsolete] @@ -15,8 +15,7 @@ public async Task TestAlterRetentionTime() { var key = CreateKeyName(); long retentionTime = 5000; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); await ts.CreateAsync(key); Assert.True(await ts.AlterAsync(key, retentionTime: retentionTime)); @@ -30,8 +29,7 @@ public async Task TestAlterRetentionTime() public async Task TestAlterLabels() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var label = new TimeSeriesLabel("key", "value"); var labels = new List { label }; @@ -53,8 +51,7 @@ public async Task TestAlterLabels() public async Task TestAlterPolicyAndChunkAsync() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); Assert.True(await ts.AlterAsync(key, chunkSizeBytes: 128, duplicatePolicy: TsDuplicatePolicy.MIN)); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs index 26185c58..f2fca20e 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreate.cs @@ -6,19 +6,16 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestCreate : AbstractNRedisStackTest, IDisposable + public class TestCreate(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "CREATE_TESTS"; - public TestCreate(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] [Obsolete] public void TestCreateOK() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key)); TimeSeriesInformation info = ts.Info(key); @@ -29,8 +26,7 @@ public void TestCreateOK() public void TestCreateRetentionTime() { long retentionTime = 5000; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, retentionTime: retentionTime)); TimeSeriesInformation info = ts.Info(key); @@ -43,8 +39,7 @@ public void TestCreateLabels() { TimeSeriesLabel label = new TimeSeriesLabel("key", "value"); var labels = new List { label }; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, labels: labels)); TimeSeriesInformation info = ts.Info(key); @@ -56,8 +51,7 @@ public void TestCreateLabels() public void TestCreateEmptyLabels() { var labels = new List(); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, labels: labels)); TimeSeriesInformation info = ts.Info(key); @@ -67,8 +61,7 @@ public void TestCreateEmptyLabels() [Fact] public void TestCreateUncompressed() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, uncompressed: true)); } @@ -76,8 +69,7 @@ public void TestCreateUncompressed() [Fact] public void TestCreatehDuplicatePolicyFirst() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, duplicatePolicy: TsDuplicatePolicy.FIRST)); } @@ -85,8 +77,7 @@ public void TestCreatehDuplicatePolicyFirst() [Fact] public void TestCreatehDuplicatePolicyLast() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, duplicatePolicy: TsDuplicatePolicy.LAST)); } @@ -94,8 +85,7 @@ public void TestCreatehDuplicatePolicyLast() [Fact] public void TestCreatehDuplicatePolicyMin() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, duplicatePolicy: TsDuplicatePolicy.MIN)); } @@ -103,8 +93,7 @@ public void TestCreatehDuplicatePolicyMin() [Fact] public void TestCreatehDuplicatePolicyMax() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, duplicatePolicy: TsDuplicatePolicy.MAX)); } @@ -112,17 +101,16 @@ public void TestCreatehDuplicatePolicyMax() [Fact] public void TestCreatehDuplicatePolicySum() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.Create(key, duplicatePolicy: TsDuplicatePolicy.SUM)); } [SkipIfRedis(Comparison.LessThan, "7.4.0")] - public void TestCreateAndIgnoreValues() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestCreateAndIgnoreValues(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var parameters = new TsCreateParamsBuilder().AddIgnoreValues(11, 12).build(); Assert.True(ts.Create(key, parameters)); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs index 36993d4b..be6c707a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestCreateAsync.cs @@ -7,14 +7,13 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestCreateAsync : AbstractNRedisStackTest { - public TestCreateAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestCreateAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] public async Task TestCreateOK() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key)); } @@ -25,8 +24,7 @@ public async Task TestCreateRetentionTime() { var key = CreateKeyName(); long retentionTime = 5000; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, retentionTime: retentionTime)); @@ -41,8 +39,7 @@ public async Task TestCreateLabels() var key = CreateKeyName(); var label = new TimeSeriesLabel("key", "value"); var labels = new List { label }; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, labels: labels)); @@ -56,8 +53,7 @@ public async Task TestCreateEmptyLabels() { var key = CreateKeyName(); var labels = new List(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, labels: labels)); @@ -69,8 +65,7 @@ public async Task TestCreateEmptyLabels() public async Task TestCreateUncompressed() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, uncompressed: true)); } @@ -79,8 +74,7 @@ public async Task TestCreateUncompressed() public async void TestCreatehDuplicatePolicyFirst() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, duplicatePolicy: TsDuplicatePolicy.FIRST)); } @@ -89,8 +83,7 @@ public async void TestCreatehDuplicatePolicyFirst() public async void TestCreatehDuplicatePolicyLast() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, duplicatePolicy: TsDuplicatePolicy.LAST)); } @@ -99,8 +92,7 @@ public async void TestCreatehDuplicatePolicyLast() public async void TestCreatehDuplicatePolicyMin() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, duplicatePolicy: TsDuplicatePolicy.MIN)); } @@ -109,8 +101,7 @@ public async void TestCreatehDuplicatePolicyMin() public async void TestCreatehDuplicatePolicyMax() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, duplicatePolicy: TsDuplicatePolicy.MAX)); } @@ -119,8 +110,7 @@ public async void TestCreatehDuplicatePolicyMax() public async void TestCreatehDuplicatePolicySum() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.CreateAsync(key, duplicatePolicy: TsDuplicatePolicy.SUM)); } diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs index 52d516c7..b99390cf 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrBy.cs @@ -5,19 +5,16 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestDecrBy : AbstractNRedisStackTest, IDisposable + public class TestDecrBy(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "DECRBY_TESTS"; - public TestDecrBy(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] public void TestDefaultDecrBy() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value) > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -27,8 +24,7 @@ public void TestDefaultDecrBy() public void TestStarDecrBy() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value, timestamp: "*") > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -38,8 +34,7 @@ public void TestStarDecrBy() public void TestDecrByTimeStamp() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, ts.DecrBy(key, -value, timestamp: timeStamp)); @@ -52,8 +47,7 @@ public void TestDefaultDecrByWithRetentionTime() { double value = 5.5; long retentionTime = 5000; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value, retentionTime: retentionTime) > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -67,8 +61,7 @@ public void TestDefaultDecrByWithLabels() { double value = 5.5; TimeSeriesLabel label = new TimeSeriesLabel("key", "value"); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var labels = new List { label }; Assert.True(ts.DecrBy(key, -value, labels: labels) > 0); @@ -81,8 +74,7 @@ public void TestDefaultDecrByWithLabels() public void TestDefaultDecrByWithUncompressed() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.DecrBy(key, -value, uncompressed: true) > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -92,8 +84,7 @@ public void TestDefaultDecrByWithUncompressed() public void TestWrongParameters() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var ex = Assert.Throws(() => ts.DecrBy(key, value, timestamp: "+")); Assert.Equal("ERR TSDB: invalid timestamp", ex.Message); @@ -102,10 +93,10 @@ public void TestWrongParameters() } [SkipIfRedis(Comparison.LessThan, "7.4.0")] - public async void TestIncrDecryByAndIgnoreValues() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async void TestIncrDecryByAndIgnoreValues(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var decrParameters = new TsDecrByParamsBuilder().AddValue(1).AddIgnoreValues(15, 16).build(); ts.DecrBy(key, decrParameters); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs index 219ebe64..67dc28eb 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDecrByAsync.cs @@ -7,15 +7,14 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestDecrByAsync : AbstractNRedisStackTest { - public TestDecrByAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestDecrByAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] public async Task TestDefaultDecrBy() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.DecrByAsync(key, -value) > 0); @@ -28,8 +27,7 @@ public async Task TestStarDecrBy() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.DecrByAsync(key, -value, timestamp: "*") > 0); @@ -42,8 +40,7 @@ public async Task TestDecrByTimeStamp() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.DecrByAsync(key, -value, timestamp: timeStamp)); @@ -57,8 +54,7 @@ public async Task TestDefaultDecrByWithRetentionTime() var key = CreateKeyName(); var value = 5.5; long retentionTime = 5000; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.DecrByAsync(key, -value, retentionTime: retentionTime) > 0); @@ -76,8 +72,7 @@ public async Task TestDefaultDecrByWithLabels() var key = CreateKeyName(); var value = 5.5; var label = new TimeSeriesLabel("key", "value"); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var labels = new List { label }; Assert.True(await ts.DecrByAsync(key, -value, labels: labels) > 0); @@ -94,8 +89,7 @@ public async Task TestDefaultDecrByWithUncompressed() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.DecrByAsync(key, -value, uncompressed: true) > 0); @@ -108,8 +102,7 @@ public async Task TestWrongParameters() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var ex = await Assert.ThrowsAsync(async () => await ts.DecrByAsync(key, value, timestamp: "+")); Assert.Equal("ERR TSDB: invalid timestamp", ex.Message); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs index b4b6134b..4cf7f140 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDel.cs @@ -10,7 +10,7 @@ public class TestDel : AbstractNRedisStackTest, IDisposable { private readonly string key = "DEL_TESTS"; - public TestDel(RedisFixture redisFixture) : base(redisFixture) { } + public TestDel(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } private List CreateData(ITimeSeriesCommands ts, int timeBucket) //TODO: check this @@ -27,8 +27,7 @@ private List CreateData(ITimeSeriesCommands ts, int timeBucket) [Fact] public void TestDelNotExists() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var ex = Assert.Throws(() => ts.Del(key, "-", "+")); Assert.Equal("ERR TSDB: the key does not exist", ex.Message); @@ -37,8 +36,7 @@ public void TestDelNotExists() [Fact] public void TestDelRange() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = CreateData(ts, 50); TimeStamp from = tuples[0].Time; diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs index 090df851..258fa8cf 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestDelAsync.cs @@ -7,7 +7,7 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestDelAsync : AbstractNRedisStackTest { - public TestDelAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestDelAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } private async Task> CreateData(TimeSeriesCommands ts, string key, int timeBucket) { @@ -24,8 +24,7 @@ private async Task> CreateData(TimeSeriesCommands ts, stri public async Task TestDelNotExists() { var key = CreateKeyName(); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var ex = await Assert.ThrowsAsync(async () => await ts.DelAsync(key, "-", "+")); Assert.Equal("ERR TSDB: the key does not exist", ex.Message); @@ -34,8 +33,7 @@ public async Task TestDelNotExists() [Fact] public async Task TestDelRange() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var key = CreateKeyName(); var tuples = await CreateData(ts, key, 50); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs index 7f8edf0a..b963e54c 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGet.cs @@ -10,14 +10,13 @@ public class TestGet : AbstractNRedisStackTest, IDisposable private readonly string key = "GET_TESTS"; - public TestGet(RedisFixture redisFixture) : base(redisFixture) { } + public TestGet(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] public void TestGetNotExists() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var ex = Assert.Throws(() => ts.Get(key)); Assert.Equal("ERR TSDB: the key does not exist", ex.Message); @@ -26,8 +25,7 @@ public void TestGetNotExists() [Fact] public void TestEmptyGet() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); Assert.Null(ts.Get(key)); @@ -38,8 +36,7 @@ public void TestAddAndGet() { DateTime now = DateTime.UtcNow; TimeSeriesTuple expected = new TimeSeriesTuple(now, 1.1); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create(key); ts.Add(key, now, 1.1); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGetAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGetAsync.cs index f30cb3a7..2c7fd576 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGetAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestGetAsync.cs @@ -7,14 +7,13 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestGetAsync : AbstractNRedisStackTest { - public TestGetAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestGetAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] public async Task TestGetNotExists() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var ex = await Assert.ThrowsAsync(async () => await ts.GetAsync(key)); Assert.Equal("ERR TSDB: the key does not exist", ex.Message); @@ -24,8 +23,7 @@ public async Task TestGetNotExists() public async Task TestEmptyGet() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); await ts.CreateAsync(key); Assert.Null(await ts.GetAsync(key)); @@ -37,8 +35,7 @@ public async Task TestAddAndGet() var key = CreateKeyName(); var now = DateTime.UtcNow; var expected = new TimeSeriesTuple(now, 1.1); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); await ts.CreateAsync(key); await ts.AddAsync(key, now, 1.1); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs index 2b6bc8c7..87538bae 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrBy.cs @@ -5,19 +5,15 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestIncrBy : AbstractNRedisStackTest, IDisposable + public class TestIncrBy(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "INCRBY_TESTS"; - public TestIncrBy(RedisFixture redisFixture) : base(redisFixture) { } - - [Fact] public void TestDefaultIncrBy() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.IncrBy(key, value) > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -27,8 +23,7 @@ public void TestDefaultIncrBy() public void TestStarIncrBy() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.IncrBy(key, value, timestamp: "*") > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -38,8 +33,7 @@ public void TestStarIncrBy() public void TestIncrByTimeStamp() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, ts.IncrBy(key, value, timestamp: timeStamp)); @@ -52,8 +46,7 @@ public void TestDefaultIncrByWithRetentionTime() { double value = 5.5; long retentionTime = 5000; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.IncrBy(key, value, retentionTime: retentionTime) > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -67,8 +60,7 @@ public void TestDefaultIncrByWithLabels() { double value = 5.5; TimeSeriesLabel label = new TimeSeriesLabel("key", "value"); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var labels = new List { label }; Assert.True(ts.IncrBy(key, value, labels: labels) > 0); @@ -81,8 +73,7 @@ public void TestDefaultIncrByWithLabels() public void TestDefaultIncrByWithUncompressed() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); Assert.True(ts.IncrBy(key, value, uncompressed: true) > 0); Assert.Equal(value, ts.Get(key)!.Val); @@ -92,8 +83,7 @@ public void TestDefaultIncrByWithUncompressed() public void TestWrongParameters() { double value = 5.5; - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var ex = Assert.Throws(() => ts.IncrBy(key, value, timestamp: "+")); Assert.Equal("ERR TSDB: invalid timestamp", ex.Message); @@ -102,10 +92,10 @@ public void TestWrongParameters() } [SkipIfRedis(Comparison.LessThan, "7.4.0")] - public async void TestIncrByAndIgnoreValues() + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async void TestIncrByAndIgnoreValues(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var incrParameters = new TsIncrByParamsBuilder().AddValue(1).AddIgnoreValues(15, 16).build(); ts.IncrBy(key, incrParameters); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs index 1c02440e..afdbbc03 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestIncrByAsync.cs @@ -7,15 +7,14 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestIncrByAsync : AbstractNRedisStackTest { - public TestIncrByAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestIncrByAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } [Fact] public async Task TestDefaultIncrBy() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.IncrByAsync(key, value) > 0); @@ -28,8 +27,7 @@ public async Task TestStarIncrBy() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.IncrByAsync(key, value, timestamp: "*") > 0); @@ -42,8 +40,7 @@ public async Task TestIncrByTimeStamp() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); TimeStamp timeStamp = DateTime.UtcNow; Assert.Equal(timeStamp, await ts.IncrByAsync(key, value, timestamp: timeStamp)); @@ -57,8 +54,7 @@ public async Task TestDefaultIncrByWithRetentionTime() var key = CreateKeyName(); var value = 5.5; long retentionTime = 5000; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.IncrByAsync(key, value, retentionTime: retentionTime) > 0); @@ -76,8 +72,7 @@ public async Task TestDefaultIncrByWithLabels() var key = CreateKeyName(); var value = 5.5; var label = new TimeSeriesLabel("key", "value"); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var labels = new List { label }; Assert.True(await ts.IncrByAsync(key, value, labels: labels) > 0); @@ -94,8 +89,7 @@ public async Task TestDefaultIncrByWithUncompressed() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); Assert.True(await ts.IncrByAsync(key, value, uncompressed: true) > 0); @@ -108,8 +102,7 @@ public async Task TestWrongParameters() { var key = CreateKeyName(); var value = 5.5; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var ex = await Assert.ThrowsAsync(async () => await ts.IncrByAsync(key, value, timestamp: "+")); Assert.Equal("ERR TSDB: invalid timestamp", ex.Message); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs index 07b0087e..ca506faf 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs @@ -6,20 +6,18 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestMADD : AbstractNRedisStackTest, IDisposable + public class TestMADD(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string[] keys = { "MADD_TESTS_1", "MADD_TESTS_2" }; - public TestMADD(RedisFixture redisFixture) : base(redisFixture) { } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestStarMADD() + public void TestStarMADD(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (string key in keys) @@ -43,12 +41,12 @@ public void TestStarMADD() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestSuccessfulMADD() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSuccessfulMADD(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (string key in keys) @@ -73,11 +71,11 @@ public void TestSuccessfulMADD() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestOverrideMADD() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestOverrideMADD(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (string key in keys) diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs index 625fdf3a..8a13005d 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs @@ -8,17 +8,17 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { public class TestMAddAsync : AbstractNRedisStackTest { - public TestMAddAsync(RedisFixture redisFixture) : base(redisFixture) { } + public TestMAddAsync(EndpointsFixture endpointsFixture) : base(endpointsFixture) { } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestStarMADD() + public async Task TestStarMADD(string endpointId) { var keys = CreateKeyNames(2); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (string key in keys) @@ -44,12 +44,12 @@ public async Task TestStarMADD() } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestSuccessfulMAdd() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSuccessfulMAdd(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in keys) @@ -74,12 +74,12 @@ public async Task TestSuccessfulMAdd() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestOverrideMAdd() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestOverrideMAdd(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in keys) diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs index e2219c54..837ce8db 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGet.cs @@ -5,18 +5,16 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestMGet : AbstractNRedisStackTest, IDisposable + public class TestMGet(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string[] keys = { "MGET_TESTS_1", "MGET_TESTS_2" }; - public TestMGet(RedisFixture redisFixture) : base(redisFixture) { } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMGetQuery() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMGetQuery(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel("MGET_TESTS_1", "value"); @@ -39,11 +37,11 @@ public void TestMGetQuery() } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMGetQueryWithLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMGetQueryWithLabels(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel("MGET_TESTS_1", "value"); @@ -66,11 +64,11 @@ public void TestMGetQueryWithLabels() Assert.Equal(labels2, results[1].labels); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMGetQuerySelectedLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMGetQuerySelectedLabels(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel("MGET_TESTS_1", "value"); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs index fb3ce257..5ad5d7ce 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMGetAsync.cs @@ -4,16 +4,14 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestMGetAsync : AbstractNRedisStackTest + public class TestMGetAsync(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestMGetAsync(RedisFixture redisFixture) : base(redisFixture) { } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMGetQuery() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMGetQuery(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel(keys[0], "value"); @@ -36,12 +34,12 @@ public async Task TestMGetQuery() Assert.Equal(new List(), results[1].labels); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMGetQueryWithLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMGetQueryWithLabels(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel(keys[0], "value"); @@ -64,12 +62,12 @@ public async Task TestMGetQueryWithLabels() Assert.Equal(labels2, results[1].labels); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMGetQuerySelectedLabelsAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMGetQuerySelectedLabelsAsync(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel("MGET_TESTS_1", "value"); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs index cd95109a..c101457c 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRange.cs @@ -6,12 +6,10 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestMRange : AbstractNRedisStackTest, IDisposable + public class TestMRange(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string[] _keys = { "MRANGE_TESTS_1", "MRANGE_TESTS_2" }; - public TestMRange(RedisFixture redisFixture) : base(redisFixture) { } - private List CreateData(ITimeSeriesCommands ts, int timeBucket, string[]? keys = null) { keys ??= _keys; @@ -29,11 +27,11 @@ private List CreateData(ITimeSeriesCommands ts, int timeBucket, return tuples; } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestSimpleMRange() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSimpleMRange(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("MRANGEkey", "MRANGEvalue"); var labels = new List { label }; @@ -52,11 +50,11 @@ public void TestSimpleMRange() Assert.Equal(tuples, results[i].values); } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeWithLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeWithLabels(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MRangeWithLabels"); var labels = new List { label }; @@ -76,11 +74,11 @@ public void TestMRangeWithLabels() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeSelectLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeSelectLabels(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label1 = new TimeSeriesLabel("key", "MRangeSelectLabels"); TimeSeriesLabel[] labels = new TimeSeriesLabel[] { new TimeSeriesLabel("team", "CTO"), new TimeSeriesLabel("team", "AUT") }; @@ -105,11 +103,11 @@ public void TestMRangeSelectLabels() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeFilter() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeFilter(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MRangeFilter"); var labels = new List { label }; @@ -122,11 +120,11 @@ public void TestMRangeFilter() Assert.Equal(tuples, results[0].values); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeCount() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeCount(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MRangeCount"); var labels = new List { label }; @@ -147,11 +145,11 @@ public void TestMRangeCount() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeAggregation() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeAggregation(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MRangeAggregation"); var labels = new List { label }; @@ -171,11 +169,11 @@ public void TestMRangeAggregation() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeAlign() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeAlign(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MRangeAlign"); var labels = new List { label }; @@ -197,8 +195,7 @@ public void TestMRangeAlign() [Fact] public void TestMissingFilter() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MissingFilter"); var labels = new List { label }; @@ -215,8 +212,7 @@ public void TestMissingFilter() [Fact] public void TestMissingTimeBucket() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MissingTimeBucket"); var labels = new List { label }; @@ -230,11 +226,11 @@ public void TestMissingTimeBucket() Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeGroupby() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeGroupby(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); for (int i = 0; i < _keys.Length; i++) { @@ -256,11 +252,11 @@ public void TestMRangeGroupby() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceSum() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceSum(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -281,11 +277,11 @@ public void TestMRangeReduceSum() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceAvg() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceAvg(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -306,11 +302,11 @@ public void TestMRangeReduceAvg() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceRange() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceRange(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -331,11 +327,11 @@ public void TestMRangeReduceRange() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceCount() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceCount(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -356,11 +352,11 @@ public void TestMRangeReduceCount() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceStdP() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceStdP(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -380,12 +376,12 @@ public void TestMRangeReduceStdP() Assert.Equal(0, results[0].values[i].Val); } } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceStdS() + + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceStdS(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -405,12 +401,12 @@ public void TestMRangeReduceStdS() Assert.Equal(0, results[0].values[i].Val); } } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceVarP() + + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceVarP(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -430,12 +426,12 @@ public void TestMRangeReduceVarP() Assert.Equal(0, results[0].values[i].Val); } } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeReduceVarS() + + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeReduceVarS(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in _keys) { @@ -456,11 +452,11 @@ public void TestMRangeReduceVarS() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeFilterBy() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeFilterBy(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel("key", "MRangeFilterBy"); var labels = new List { label }; @@ -483,11 +479,11 @@ public void TestMRangeFilterBy() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRangeLatest() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRangeLatest(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel("key", "MRangeLatest"); var compactedLabel = new TimeSeriesLabel("compact", "true"); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs index 3f0c6899..7ff3b3dd 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRangeAsync.cs @@ -6,10 +6,8 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestMRangeAsync : AbstractNRedisStackTest + public class TestMRangeAsync(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestMRangeAsync(RedisFixture redisFixture) : base(redisFixture) { } - private async Task> CreateData(TimeSeriesCommands ts, string[] keys, int timeBucket) { var tuples = new List(); @@ -27,12 +25,12 @@ private async Task> CreateData(TimeSeriesCommands ts, stri return tuples; } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestSimpleMRange() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSimpleMRange(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -51,12 +49,13 @@ public async Task TestSimpleMRange() Assert.Equal(tuples, results[i].values); } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeWithLabels() + + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeWithLabels(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -76,12 +75,12 @@ public async Task TestMRangeWithLabels() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeSelectLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeSelectLabels(string endpointId) { var keys = CreateKeyNames(2); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label1 = new TimeSeriesLabel(keys[0], "value"); TimeSeriesLabel[] labels = new TimeSeriesLabel[] { new TimeSeriesLabel("team", "CTO"), new TimeSeriesLabel("team", "AUT") }; @@ -110,12 +109,12 @@ await ts.MRangeAsync("-", "+", } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeFilter() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeFilter(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -128,12 +127,12 @@ public async Task TestMRangeFilter() Assert.Equal(tuples, results[0].values); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeCount() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeCount(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -154,12 +153,12 @@ public async Task TestMRangeCount() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeAggregation() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeAggregation(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -179,12 +178,12 @@ public async Task TestMRangeAggregation() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeAlign() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeAlign(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -203,12 +202,12 @@ public async Task TestMRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMissingFilter() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMissingFilter(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -222,12 +221,12 @@ public async Task TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMissingTimeBucket() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMissingTimeBucket(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -245,12 +244,13 @@ await ts.MRangeAsync("-", "+", }); Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeGroupby() + + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeGroupby(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); for (int i = 0; i < keys.Length; i++) { @@ -272,12 +272,12 @@ public async Task TestMRangeGroupby() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeReduce() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeReduce(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in keys) { @@ -298,12 +298,12 @@ public async Task TestMRangeReduce() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeFilterBy() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeFilterBy(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs index 4399ac18..78f9a79e 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRange.cs @@ -6,10 +6,8 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestMRevRange : AbstractNRedisStackTest + public class TestMRevRange(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestMRevRange(RedisFixture redisFixture) : base(redisFixture) { } - private List CreateData(ITimeSeriesCommands ts, string[] keys, int timeBucket) { var tuples = new List(); @@ -20,19 +18,18 @@ private List CreateData(ITimeSeriesCommands ts, string[] keys, foreach (var key in keys) { ts.Add(key, timeStamp, i); - } tuples.Add(new TimeSeriesTuple(timeStamp, i)); } return tuples; } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestSimpleMRevRange() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSimpleMRevRange(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -52,12 +49,12 @@ public void TestSimpleMRevRange() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeWithLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeWithLabels(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -78,12 +75,12 @@ public void TestMRevRangeWithLabels() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeSelectLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeSelectLabels(string endpointId) { var keys = CreateKeyNames(2); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label1 = new TimeSeriesLabel("key", "MRangeSelectLabels"); TimeSeriesLabel[] labels = new TimeSeriesLabel[] { new TimeSeriesLabel("team", "CTO"), new TimeSeriesLabel("team", "AUT") }; @@ -103,12 +100,12 @@ public void TestMRevRangeSelectLabels() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeFilter() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeFilter(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -121,12 +118,12 @@ public void TestMRevRangeFilter() Assert.Equal(ReverseData(tuples), results[0].values); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeCount() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeCount(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -147,12 +144,12 @@ public void TestMRevRangeCount() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeAggregation() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeAggregation(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -172,12 +169,12 @@ public void TestMRevRangeAggregation() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeAlign() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeAlign(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -196,12 +193,12 @@ public void TestMRevRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMissingFilter() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMissingFilter(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -215,12 +212,12 @@ public void TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMissingTimeBucket() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMissingTimeBucket(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -234,12 +231,12 @@ public void TestMissingTimeBucket() Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeGroupby() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeGroupby(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); for (int i = 0; i < keys.Length; i++) { @@ -261,12 +258,12 @@ public void TestMRevRangeGroupby() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeReduce() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeReduce(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in keys) { @@ -288,12 +285,12 @@ public void TestMRevRangeReduce() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestMRevRangeFilterBy() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMRevRangeFilterBy(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs index d2327c11..f9ea4262 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMRevRangeAsync.cs @@ -6,10 +6,8 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestMRevRangeAsync : AbstractNRedisStackTest + public class TestMRevRangeAsync(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestMRevRangeAsync(RedisFixture redisFixture) : base(redisFixture) { } - private async Task> CreateData(TimeSeriesCommands ts, string[] keys, int timeBucket) { var tuples = new List(); @@ -27,12 +25,12 @@ private async Task> CreateData(TimeSeriesCommands ts, stri return tuples; } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestSimpleMRevRange() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSimpleMRevRange(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -52,12 +50,12 @@ public async Task TestSimpleMRevRange() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeWithLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeWithLabels(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -77,12 +75,12 @@ public async Task TestMRevRangeWithLabels() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeSelectLabels() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeSelectLabels(string endpointId) { var keys = CreateKeyNames(2); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label1 = new TimeSeriesLabel(keys[0], "value"); TimeSeriesLabel[] labels = new TimeSeriesLabel[] { new TimeSeriesLabel("team", "CTO"), new TimeSeriesLabel("team", "AUT") }; @@ -102,12 +100,12 @@ public async Task TestMRevRangeSelectLabels() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeFilter() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeFilter(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -120,12 +118,12 @@ public async Task TestMRevRangeFilter() Assert.Equal(ReverseData(tuples), results[0].values); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeCount() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeCount(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -146,12 +144,12 @@ public async Task TestMRevRangeCount() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRangeAggregation() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRangeAggregation(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -171,12 +169,12 @@ public async Task TestMRangeAggregation() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeAlign() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeAlign(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -195,12 +193,12 @@ public async Task TestMRevRangeAlign() Assert.Equal(expected[0], results[0].values[0]); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMissingFilter() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMissingFilter(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -214,12 +212,12 @@ public async Task TestMissingFilter() Assert.Equal("There should be at least one filter on MRANGE/MREVRANGE", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMissingTimeBucket() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMissingTimeBucket(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -238,12 +236,12 @@ await ts.MRevRangeAsync("-", "+", Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeGroupby() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeGroupby(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); for (int i = 0; i < keys.Length; i++) { @@ -265,12 +263,12 @@ public async Task TestMRevRangeGroupby() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeReduce() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeReduce(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); foreach (var key in keys) { @@ -292,12 +290,12 @@ public async Task TestMRevRangeReduce() } } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestMRevRangeFilterBy() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMRevRangeFilterBy(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); TimeSeriesLabel label = new TimeSeriesLabel(keys[0], "value"); var labels = new List { label }; @@ -320,4 +318,4 @@ public async Task TestMRevRangeFilterBy() } } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs index cd49bad4..994f788d 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndex.cs @@ -4,17 +4,15 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestQueryIndex : AbstractNRedisStackTest, IDisposable + public class TestQueryIndex(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string[] keys = { "QUERYINDEX_TESTS_1", "QUERYINDEX_TESTS_2" }; - public TestQueryIndex(RedisFixture redisFixture) : base(redisFixture) { } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestTSQueryIndex() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestTSQueryIndex(string endpointId) { - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel("QUERYINDEX_TESTS_1", "value"); var label2 = new TimeSeriesLabel("QUERYINDEX_TESTS_2", "value2"); @@ -27,4 +25,4 @@ public void TestTSQueryIndex() Assert.Equal(new List { keys[0] }, ts.QueryIndex(new List { "QUERYINDEX_TESTS_2=value2" })); } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs index 92a084bd..f2980042 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestQueryIndexAsync.cs @@ -4,16 +4,14 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestQueryIndexAsync : AbstractNRedisStackTest + public class TestQueryIndexAsync(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestQueryIndexAsync(RedisFixture redisFixture) : base(redisFixture) { } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestTSQueryIndex() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestTSQueryIndex(string endpointId) { var keys = CreateKeyNames(2); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var label1 = new TimeSeriesLabel(keys[0], "value"); var label2 = new TimeSeriesLabel(keys[1], "value2"); @@ -26,4 +24,4 @@ public async Task TestTSQueryIndex() Assert.Equal(new List { keys[0] }, ts.QueryIndex(new List { $"{keys[1]}=value2" })); } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs index 00bda2b4..f4ee604b 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRange.cs @@ -6,13 +6,10 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestRange : AbstractNRedisStackTest, IDisposable + public class TestRange(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "RANGE_TESTS"; - public TestRange(RedisFixture redisFixture) : base(redisFixture) { } - - private List CreateData(ITimeSeriesCommands ts, int timeBucket) { var tuples = new List(); @@ -27,8 +24,7 @@ private List CreateData(ITimeSeriesCommands ts, int timeBucket) [Fact] public void TestSimpleRange() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = CreateData(ts, 50); Assert.Equal(tuples, ts.Range(key, "-", "+")); @@ -37,8 +33,7 @@ public void TestSimpleRange() [Fact] public void TestRangeCount() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = CreateData(ts, 50); Assert.Equal(tuples.GetRange(0, 5), ts.Range(key, "-", "+", count: 5)); @@ -47,8 +42,7 @@ public void TestRangeCount() [Fact] public void TestRangeAggregation() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = CreateData(ts, 50); Assert.Equal(tuples, ts.Range(key, "-", "+", aggregation: TsAggregation.Min, timeBucket: 50)); @@ -57,8 +51,7 @@ public void TestRangeAggregation() [Fact] public void TestRangeAlign() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = new List() { @@ -98,8 +91,7 @@ public void TestRangeAlign() [Fact] public void TestMissingTimeBucket() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = CreateData(ts, 50); var ex = Assert.Throws(() => ts.Range(key, "-", "+", aggregation: TsAggregation.Avg)); @@ -109,8 +101,7 @@ public void TestMissingTimeBucket() [Fact] public void TestFilterBy() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = CreateData(ts, 50); @@ -126,11 +117,11 @@ public void TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void latest() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void latest(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); ts.Create("ts1"); ts.Create("ts2"); @@ -161,11 +152,11 @@ public void latest() Assert.Equal(new List() { latest, compact }, ts.RevRange("ts2", 0, 10, true)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestAlignTimestamp() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAlignTimestamp(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); ts.Create("ts1"); ts.Create("ts2"); @@ -182,8 +173,7 @@ public void TestAlignTimestamp() [Fact] public void TestBucketTimestamp() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create("t1"); @@ -242,8 +232,7 @@ public void TestBucketTimestamp() [Fact] public void TestEmpty() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create("t1"); diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs index ab9aba4d..4edfdcc6 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRangeAsync.cs @@ -6,10 +6,8 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestRangeAsync : AbstractNRedisStackTest + public class TestRangeAsync(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestRangeAsync(RedisFixture redisFixture) : base(redisFixture) { } - private async Task> CreateData(TimeSeriesCommands ts, string key, int timeBucket) { var tuples = new List(); @@ -25,8 +23,7 @@ private async Task> CreateData(TimeSeriesCommands ts, stri public async Task TestSimpleRange() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); Assert.Equal(tuples, await ts.RangeAsync(key, "-", "+")); @@ -36,8 +33,7 @@ public async Task TestSimpleRange() public async Task TestRangeCount() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); Assert.Equal(tuples.GetRange(0, 5), await ts.RangeAsync(key, "-", "+", count: 5)); @@ -47,8 +43,7 @@ public async Task TestRangeCount() public async Task TestRangeAggregation() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); Assert.Equal(tuples, await ts.RangeAsync(key, "-", "+", aggregation: TsAggregation.Min, timeBucket: 50)); @@ -58,8 +53,7 @@ public async Task TestRangeAggregation() public async Task TestRangeAlign() { var key = CreateKeyName(); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); var tuples = new List() { @@ -100,8 +94,7 @@ public async Task TestRangeAlign() public async Task TestMissingTimeBucket() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); var ex = await Assert.ThrowsAsync(async () => await ts.RangeAsync(key, "-", "+", aggregation: TsAggregation.Avg)); @@ -112,8 +105,7 @@ public async Task TestMissingTimeBucket() public async Task TestFilterBy() { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); @@ -129,11 +121,11 @@ public async Task TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestLatestAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestLatestAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); await ts.CreateAsync("ts1"); await ts.CreateAsync("ts2"); @@ -164,11 +156,11 @@ public async Task TestLatestAsync() Assert.Equal(new List() { latest, compact }, await ts.RevRangeAsync("ts2", 0, 10, true)); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestAlignTimestampAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAlignTimestampAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); ts.Create("ts1"); ts.Create("ts2"); @@ -185,8 +177,7 @@ public async Task TestAlignTimestampAsync() [Fact] public async Task TestBucketTimestampAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create("t1"); @@ -247,8 +238,7 @@ public async Task TestBucketTimestampAsync() [Fact] public async Task TestEmptyAsync() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Create("t1"); @@ -293,4 +283,4 @@ public async Task TestEmptyAsync() } } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRange.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRange.cs index bff63d04..6e681d76 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRange.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRange.cs @@ -5,10 +5,8 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestRevRange : AbstractNRedisStackTest + public class TestRevRange(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestRevRange(RedisFixture redisFixture) : base(redisFixture) { } - private List CreateData(ITimeSeriesCommands ts, string key, int timeBucket) { var tuples = new List(); @@ -21,44 +19,44 @@ private List CreateData(ITimeSeriesCommands ts, string key, int } [SkipIfRedis(Is.Enterprise)] - public void TestSimpleRevRange() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestSimpleRevRange(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = CreateData(ts, key, 50); Assert.Equal(ReverseData(tuples), ts.RevRange(key, "-", "+")); } [SkipIfRedis(Is.Enterprise)] - public void TestRevRangeCount() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestRevRangeCount(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = CreateData(ts, key, 50); Assert.Equal(ReverseData(tuples).GetRange(0, 5), ts.RevRange(key, "-", "+", count: 5)); } [SkipIfRedis(Is.Enterprise)] - public void TestRevRangeAggregation() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestRevRangeAggregation(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = CreateData(ts, key, 50); Assert.Equal(ReverseData(tuples), ts.RevRange(key, "-", "+", aggregation: TsAggregation.Min, timeBucket: 50)); } [SkipIfRedis(Is.Enterprise)] - public void TestRevRangeAlign() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestRevRangeAlign(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = new List() { @@ -96,24 +94,23 @@ public void TestRevRangeAlign() } [SkipIfRedis(Is.Enterprise)] - public void TestMissingTimeBucket() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestMissingTimeBucket(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = CreateData(ts, key, 50); var ex = Assert.Throws(() => ts.RevRange(key, "-", "+", aggregation: TsAggregation.Avg)); Assert.Equal("RANGE Aggregation should have timeBucket value", ex.Message); - } [SkipIfRedis(Is.Enterprise)] - public void TestFilterBy() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestFilterBy(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = CreateData(ts, key, 50); @@ -129,4 +126,4 @@ public void TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRangeAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRangeAsync.cs index 98703e04..9d68fe1a 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRangeAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRevRangeAsync.cs @@ -6,10 +6,8 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestRevRangeAsync : AbstractNRedisStackTest + public class TestRevRangeAsync(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestRevRangeAsync(RedisFixture redisFixture) : base(redisFixture) { } - private async Task> CreateData(TimeSeriesCommands ts, string key, int timeBucket) { var tuples = new List(); @@ -22,44 +20,44 @@ private async Task> CreateData(TimeSeriesCommands ts, stri } [SkipIfRedis(Is.Enterprise)] - public async Task TestSimpleRevRange() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestSimpleRevRange(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); Assert.Equal(ReverseData(tuples), await ts.RevRangeAsync(key, "-", "+")); } [SkipIfRedis(Is.Enterprise)] - public async Task TestRevRangeCount() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestRevRangeCount(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); Assert.Equal(ReverseData(tuples).GetRange(0, 5), await ts.RevRangeAsync(key, "-", "+", count: 5)); } [SkipIfRedis(Is.Enterprise)] - public async Task TestRevRangeAggregation() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestRevRangeAggregation(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); Assert.Equal(ReverseData(tuples), await ts.RevRangeAsync(key, "-", "+", aggregation: TsAggregation.Min, timeBucket: 50)); } [SkipIfRedis(Is.Enterprise)] - public async Task TestRevRangeAlign() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestRevRangeAlign(string endpointId) { var key = CreateKeyName(); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = new List() { @@ -97,11 +95,11 @@ public async Task TestRevRangeAlign() } [SkipIfRedis(Is.Enterprise)] - public async Task TestMissingTimeBucket() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestMissingTimeBucket(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); var ex = await Assert.ThrowsAsync(async () => await ts.RevRangeAsync(key, "-", "+", aggregation: TsAggregation.Avg)); @@ -109,11 +107,11 @@ public async Task TestMissingTimeBucket() } [SkipIfRedis(Is.Enterprise)] - public async Task TestFilterBy() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestFilterBy(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); var tuples = await CreateData(ts, key, 50); @@ -129,4 +127,4 @@ public async Task TestFilterBy() Assert.Equal(tuples.GetRange(2, 1), res); } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs index 5fab3c9a..ea658f4b 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRules.cs @@ -12,9 +12,8 @@ public class TestRules : AbstractNRedisStackTest, IDisposable private Dictionary destKeys; - public TestRules(RedisFixture redisFixture) : base(redisFixture) + public TestRules(EndpointsFixture endpointsFixture) : base(endpointsFixture) { - destKeys = new Dictionary { { TsAggregation.Avg, "RULES_DEST_" + TsAggregation.Avg }, @@ -32,12 +31,12 @@ public TestRules(RedisFixture redisFixture) : base(redisFixture) }; } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestRulesAdditionDeletion() + public void TestRulesAdditionDeletion(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); ts.Create(srcKey); foreach (var destKey in destKeys.Values) @@ -69,8 +68,7 @@ public void TestRulesAdditionDeletion() [Fact] public void TestNonExistingSrc() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); string destKey = "RULES_DEST_" + TsAggregation.Avg; ts.Create(destKey); @@ -84,8 +82,7 @@ public void TestNonExistingSrc() [Fact] public void TestNonExisitingDestinaion() { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); string destKey = "RULES_DEST_" + TsAggregation.Avg; ts.Create(srcKey); @@ -96,11 +93,11 @@ public void TestNonExisitingDestinaion() Assert.Equal("ERR TSDB: compaction rule does not exist", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public void TestAlignTimestamp() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestAlignTimestamp(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); ts.Create("ts1"); ts.Create("ts2"); @@ -120,4 +117,4 @@ public void TestAlignTimestamp() Assert.Equal(1, ts.Range("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10).Count); } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs index 3724d139..09e295e1 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestAPI/TestRulesAsync.cs @@ -6,17 +6,15 @@ namespace NRedisStack.Tests.TimeSeries.TestAPI { - public class TestRulesAsync : AbstractNRedisStackTest + public class TestRulesAsync(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { - public TestRulesAsync(RedisFixture redisFixture) : base(redisFixture) { } - - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public async Task TestRulesAdditionDeletion() + public async Task TestRulesAdditionDeletion(string endpointId) { var key = CreateKeyName(); - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); await ts.CreateAsync(key); var aggregations = (TsAggregation[])Enum.GetValues(typeof(TsAggregation)); @@ -54,12 +52,12 @@ public async Task TestRulesAdditionDeletion() } [SkipIfRedis(Is.Enterprise)] - public async Task TestNonExistingSrc() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestNonExistingSrc(string endpointId) { var key = CreateKeyName(); var aggKey = $"{key}:{TsAggregation.Avg}"; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); await ts.CreateAsync(aggKey); var rule = new TimeSeriesRule(aggKey, 50, TsAggregation.Avg); @@ -73,12 +71,12 @@ public async Task TestNonExistingSrc() } [SkipIfRedis(Is.Enterprise)] - public async Task TestNonExisitingDestinaion() + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestNonExisitingDestinaion(string endpointId) { var key = CreateKeyName(); var aggKey = $"{key}:{TsAggregation.Avg}"; - var db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + var db = GetCleanDatabase(endpointId); var ts = db.TS(); await ts.CreateAsync(key); var rule = new TimeSeriesRule(aggKey, 50, TsAggregation.Avg); @@ -89,11 +87,11 @@ public async Task TestNonExisitingDestinaion() Assert.Equal("ERR TSDB: compaction rule does not exist", ex.Message); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] - public async Task TestAlignTimestampAsync() + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public async Task TestAlignTimestampAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var ts = db.TS(); await ts.CreateAsync("ts1"); await ts.CreateAsync("ts2"); @@ -113,4 +111,4 @@ public async Task TestAlignTimestampAsync() Assert.Equal(1, (await ts.RangeAsync("ts3", "-", "+", aggregation: TsAggregation.Count, timeBucket: 10)).Count); } } -} +} \ No newline at end of file diff --git a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs index e3e43daa..909ba5aa 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TestDataTypes/TestTimeSeriesInformation.cs @@ -8,17 +8,15 @@ namespace NRedisTimeSeries.Test.TestDataTypes { - public class TestInformation : AbstractNRedisStackTest + public class TestInformation(NRedisStack.Tests.EndpointsFixture endpointsFixture) + : AbstractNRedisStackTest(endpointsFixture) { - public TestInformation(NRedisStack.Tests.RedisFixture redisFixture) : base(redisFixture) { } - [Fact] [Obsolete] public void TestInformationSync() { string key = CreateKeyName(); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); ts.Add(key, "*", 1.1); ts.Add(key, "*", 1.3, duplicatePolicy: TsDuplicatePolicy.LAST); @@ -46,8 +44,7 @@ public void TestInformationSync() public async Task TestInformationAsync() { string key = CreateKeyName(); - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(); var ts = db.TS(); await ts.AddAsync(key, "*", 1.1); await ts.AddAsync(key, "*", 1.3, duplicatePolicy: TsDuplicatePolicy.LAST); diff --git a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs index cf7615a8..46651651 100644 --- a/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs +++ b/tests/NRedisStack.Tests/TimeSeries/TimeSeriesTests.cs @@ -5,26 +5,14 @@ namespace NRedisStack.Tests.TimeSeries; -public class TimeSeriesTests : AbstractNRedisStackTest, IDisposable +public class TimeSeriesTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { - // private readonly string key = "TIME_SERIES_TESTS"; - public TimeSeriesTests(RedisFixture redisFixture) : base(redisFixture) { } - - // [Fact] - // public void TestCreateOK() - // { - // IDatabase db = redisFixture.Redis.GetDatabase(); - // var result = ts.Create(key); - // Assert.True(result); - // //TimeSeriesInformation info = ts.Info(key); - // } - - [Fact] public void TestModulePrefixs() { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(); + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var ts1 = db1.TS(); var ts2 = db2.TS(); diff --git a/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs b/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs index db8842c2..85e39473 100644 --- a/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs +++ b/tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs @@ -6,16 +6,15 @@ namespace NRedisStack.Tests.TokenBasedAuthentication { - public class AuthenticationTests : AbstractNRedisStackTest + public class AuthenticationTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture) { static readonly string key = "myKey"; static readonly string value = "myValue"; static readonly string index = "myIndex"; static readonly string field = "myField"; static readonly string alias = "myAlias"; - public AuthenticationTests(RedisFixture redisFixture) : base(redisFixture) { } - [TargetEnvironment("standalone-entraid-acl")] + [SkippableFact] public void TestTokenBasedAuthentication() { @@ -23,7 +22,7 @@ public void TestTokenBasedAuthentication() configurationOptions.Ssl = false; configurationOptions.AbortOnConnectFail = true; // Fail fast for the purposes of this sample. In production code, this should remain false to retry connections on startup - ConnectionMultiplexer? connectionMultiplexer = redisFixture.GetConnectionById(configurationOptions, "standalone-entraid-acl"); + ConnectionMultiplexer? connectionMultiplexer = GetConnection(configurationOptions, "standalone-entraid-acl"); IDatabase db = connectionMultiplexer.GetDatabase(); diff --git a/tests/NRedisStack.Tests/TopK/TopKTests.cs b/tests/NRedisStack.Tests/TopK/TopKTests.cs index 295a279e..781e3c8e 100644 --- a/tests/NRedisStack.Tests/TopK/TopKTests.cs +++ b/tests/NRedisStack.Tests/TopK/TopKTests.cs @@ -4,17 +4,16 @@ namespace NRedisStack.Tests.TopK; -public class TopKTests : AbstractNRedisStackTest, IDisposable +public class TopKTests(EndpointsFixture endpointsFixture) : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "TOPK_TESTS"; - public TopKTests(RedisFixture redisFixture) : base(redisFixture) { } - [Fact] - public void CreateTopKFilter() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void CreateTopKFilter(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var topk = db.TOPK(); //db.KeyDelete(key, CommandFlags.FireAndForget); @@ -47,11 +46,11 @@ public void CreateTopKFilter() Assert.Equal(2000, info.Width); } - [Fact] - public async Task CreateTopKFilterAsync() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public async Task CreateTopKFilterAsync(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var topk = db.TOPK(); await topk.ReserveAsync(key, 30, 2000, 7, 0.925); @@ -83,11 +82,13 @@ public async Task CreateTopKFilterAsync() Assert.Equal(2000, info.Width); } - [Fact] - public void TestModulePrefixs() + [Theory] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] + public void TestModulePrefixs(string endpointId) { - IDatabase db1 = redisFixture.Redis.GetDatabase(); - IDatabase db2 = redisFixture.Redis.GetDatabase(); + var redis = GetConnection(endpointId); + IDatabase db1 = redis.GetDatabase(); + IDatabase db2 = redis.GetDatabase(); var topk1 = db1.TOPK(); var topk2 = db2.TOPK(); diff --git a/tests/NRedisStack.Tests/TransactionsTests.cs b/tests/NRedisStack.Tests/TransactionsTests.cs index 0883bcf1..52dce378 100644 --- a/tests/NRedisStack.Tests/TransactionsTests.cs +++ b/tests/NRedisStack.Tests/TransactionsTests.cs @@ -6,19 +6,16 @@ namespace NRedisStack.Tests; -public class TransactionTests : AbstractNRedisStackTest, IDisposable +public class TransactionTests(EndpointsFixture endpointsFixture) + : AbstractNRedisStackTest(endpointsFixture), IDisposable { private readonly string key = "TRX_TESTS"; - public TransactionTests(RedisFixture redisFixture) : base(redisFixture) + [Theory] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] + public void TestJsonTransaction(string endpointId) { - } - - [Fact] - public void TestJsonTransaction() - { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var transaction = new Transaction(db); string jsonPerson = JsonSerializer.Serialize(new Person { Name = "Shachar", Age = 23 }); var setResponse = transaction.Json.SetAsync(key, "$", jsonPerson); @@ -34,11 +31,11 @@ public void TestJsonTransaction() } [SkipIfRedis(Comparison.GreaterThanOrEqual, "7.1.242")] + [MemberData(nameof(EndpointsFixture.Env.AllEnvironments), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestModulesTransaction() + public void TestModulesTransaction(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tran = new Transaction(db); _ = tran.Bf.ReserveAsync("bf-key", 0.001, 100); @@ -85,12 +82,12 @@ public void TestModulesTransaction() Assert.NotNull(db.TOPK().Info("topk-key")); } - [SkipIfRedis(Is.OSSCluster, Is.Enterprise)] + [SkipIfRedis(Is.Enterprise)] + [MemberData(nameof(EndpointsFixture.Env.StandaloneOnly), MemberType = typeof(EndpointsFixture.Env))] [Obsolete] - public void TestModulesTransactionWithoutGraph() + public void TestModulesTransactionWithoutGraph(string endpointId) { - IDatabase db = redisFixture.Redis.GetDatabase(); - db.Execute("FLUSHALL"); + IDatabase db = GetCleanDatabase(endpointId); var tran = new Transaction(db); _ = tran.Bf.ReserveAsync("bf-key", 0.001, 100); diff --git a/tests/dockers/docker-compose.yml b/tests/dockers/docker-compose.yml new file mode 100644 index 00000000..44da6361 --- /dev/null +++ b/tests/dockers/docker-compose.yml @@ -0,0 +1,41 @@ +--- + +services: + + redis: + image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v1} + container_name: redis-standalone + environment: + - TLS_ENABLED=yes + - REDIS_CLUSTER=no + - PORT=6379 + - TLS_PORT=6666 + command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""} + ports: + - 6379:6379 + - 6666:6666 # TLS port + volumes: + - "./standalone:/redis/work" + profiles: + - standalone + - all + + cluster: + image: ${CLIENT_LIBS_TEST_IMAGE:-redislabs/client-libs-test:rs-7.4.0-v1} + container_name: redis-cluster + environment: + - REDIS_CLUSTER=yes + - NODES=6 + - REPLICAS=1 + - TLS_ENABLED=yes + - PORT=16379 + - TLS_PORT=27379 + command: ${REDIS_EXTRA_ARGS:---enable-debug-command yes --enable-module-command yes --tls-auth-clients optional --save ""} + ports: + - "16379-16384:16379-16384" + - "27379-27384:27379-27384" + volumes: + - "./cluster:/redis/work" + profiles: + - cluster + - all \ No newline at end of file diff --git a/tests/dockers/endpoints.json b/tests/dockers/endpoints.json new file mode 100644 index 00000000..1afd1fda --- /dev/null +++ b/tests/dockers/endpoints.json @@ -0,0 +1,17 @@ +{ + "standalone":{ + "endpoints": [ + "localhost:6379" + ] + }, + "cluster": { + "endpoints": [ + "localhost:16379", + "localhost:16380", + "localhost:16381", + "localhost:16382", + "localhost:16383", + "localhost:16384" + ] + } +} \ No newline at end of file