Skip to content

Commit 26a1d0e

Browse files
authored
Revamp tests (#350)
* Revamp tests: - Use endpoints.json instead of hardcoded configs - Use client-libs-test image - Add run-tests action - Use [Theory] based approach to run tests against multiple endpoints - Remove old config and env files - Use stack-based images - Use xunit.skippablefact * Add fixes * Use explicit constructors * Make dotnet format happy * Skip EntraId tests correctly * Format * Try to run docker compose on Windows image * Remove old docker-compose.yml * Rollback windows experiments * Add missing dependency * Replace the endpoints file * Use skippable theories * Move redis-server start to a separate step * Fix endpoints.json patching for .Net481 target * Fix * Add delay in flaky async test * Skip test due to found bug * Improve integration workflow * Rollback version bump * Fix formatting
1 parent c54f639 commit 26a1d0e

File tree

90 files changed

+2596
-2818
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2596
-2818
lines changed

.github/actions/run-tests/action.yml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: 'Run NRedisStack tests'
2+
description: 'Runs NRedisStack tests against different Redis versions and configurations'
3+
inputs:
4+
dotnet-version:
5+
description: 'SDK version'
6+
required: true
7+
redis-version:
8+
description: 'Redis version to test against'
9+
required: true
10+
verify-nuget-package:
11+
description: 'Verify Nuget package'
12+
required: false
13+
default: 'false'
14+
REDIS_CA_PEM:
15+
description: 'Redis CA PEM'
16+
required: true
17+
REDIS_USER_CRT:
18+
description: 'Redis User CRT'
19+
required: true
20+
REDIS_USER_PRIVATE_KEY:
21+
description: 'Redis User Private Key'
22+
required: true
23+
runs:
24+
using: "composite"
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Install .NET Core
29+
uses: actions/setup-dotnet@v4
30+
with:
31+
dotnet-version: ${{inputs.dotnet-version}}
32+
dotnet-quality: 'ga'
33+
34+
- name: Setup Environment variables and run Redis
35+
env:
36+
REDIS_VERSION: ${{ inputs.redis-version }}
37+
REDIS_IMAGE: "redis:${{ inputs.redis-version }}"
38+
CLIENT_LIBS_TEST_IMAGE: "redislabs/client-libs-test:${{ inputs.redis-version }}"
39+
run: |
40+
set -e
41+
42+
echo "::group::Setup Environment variables and run Redis"
43+
dotnet_major_minor_version=$(echo "${{ inputs.dotnet-version }}" | grep -oP '^\d+\.\d+')
44+
echo "CLR_VERSION=net${dotnet_major_minor_version}" >> $GITHUB_ENV
45+
46+
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
47+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
48+
49+
if (( redis_major_version < 8 )); then
50+
echo "Using redis-stack for module tests"
51+
52+
# Mapping of redis version to stack version
53+
declare -A redis_stack_version_mapping=(
54+
["7.4.1"]="rs-7.4.0-v1"
55+
["7.2.6"]="rs-7.2.0-v13"
56+
["6.2.16"]="rs-6.2.6-v17"
57+
)
58+
59+
if [[ -v redis_stack_version_mapping[$REDIS_VERSION] ]]; then
60+
export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:${redis_stack_version_mapping[$REDIS_VERSION]}"
61+
else
62+
echo "Version not found in the mapping."
63+
exit 1
64+
fi
65+
66+
if (( redis_major_version < 7 )); then
67+
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
68+
fi
69+
70+
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
71+
else
72+
echo "Using redis CE for module tests"
73+
export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:$REDIS_VERSION"
74+
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
75+
fi
76+
echo "::endgroup::"
77+
shell: bash
78+
79+
# Make sure only the desired dotnet version is set both as target and as active SDK.
80+
- name: Tweak target frameworks
81+
shell: bash
82+
run: |
83+
find . -name '*.csproj' | xargs -I {} sed -E -i "s|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|" {}
84+
find . -name '*.csproj' | xargs cat
85+
jq -n --arg version ${{inputs.dotnet-version}} '{"sdk":{"version":$version,"rollForward":"latestMinor"}}' > global.json
86+
- name: Check .NET version
87+
shell: bash
88+
run: dotnet --version
89+
- name: Check .NET SDKs
90+
shell: bash
91+
run: dotnet --list-sdks
92+
- name: Check .NET runtimes
93+
shell: bash
94+
run: dotnet --list-runtimes
95+
- name: Restore dependencies
96+
shell: bash
97+
run: dotnet restore
98+
99+
- name: Build
100+
shell: bash
101+
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
102+
103+
- name: Test
104+
shell: bash
105+
run: |
106+
echo "::group::Run tests"
107+
echo "${{inputs.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_ca.pem
108+
echo "${{inputs.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user.crt
109+
echo "${{inputs.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user_private.key
110+
dotnet test -f ${CLR_VERSION} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -p:BuildInParallel=false tests/Test.proj --logger GitHubActions
111+
echo "::endgroup::"
112+
- name: Codecov
113+
uses: codecov/codecov-action@v4
114+
with:
115+
verbose: true
116+
- name: Build
117+
shell: bash
118+
run: dotnet pack -c Release
119+
120+
- name: Test against Nuget package from local source
121+
if: inputs.verify-nuget-package == 'true'
122+
working-directory: PackageVerification
123+
shell: bash
124+
run: |
125+
echo "::group::Test against Nuget package from local source"
126+
mkdir -p test-source
127+
dotnet nuget add source $(readlink -f test-source) -n test-source
128+
find .. -name '*.nupkg' | xargs -I {} dotnet nuget push {} -s test-source
129+
ls -R
130+
dotnet nuget remove source nuget.org
131+
dotnet nuget list source
132+
find . -name '*.csproj' | xargs -I {} sed -E -i 's|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|' {}
133+
dotnet restore -s test-source -v detailed
134+
dotnet run
135+
echo "::endgroup::"
136+

.github/docker-compose.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/dockers/Dockerfile.cluster

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/dockers/cluster.redis.conf

Lines changed: 0 additions & 8 deletions
This file was deleted.

.github/dockers/create_cluster.sh

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)