Skip to content

Commit f14b0a3

Browse files
committed
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
1 parent 38dc1e9 commit f14b0a3

File tree

90 files changed

+2531
-2874
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

+2531
-2874
lines changed

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

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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+
dotnet_major_minor_version=$(echo "${{ inputs.dotnet-version }}" | grep -oP '^\d+\.\d+')
43+
echo "CLR_VERSION=net${dotnet_major_minor_version}" >> $GITHUB_ENV
44+
45+
redis_major_version=$(echo "$REDIS_VERSION" | grep -oP '^\d+')
46+
echo "REDIS_MAJOR_VERSION=${redis_major_version}" >> $GITHUB_ENV
47+
48+
if (( redis_major_version < 8 )); then
49+
echo "Using redis-stack for module tests"
50+
51+
# Mapping of redis version to stack version
52+
declare -A redis_stack_version_mapping=(
53+
["7.4.1"]="rs-7.4.0-v1"
54+
["7.2.6"]="rs-7.2.0-v13"
55+
["6.2.16"]="rs-6.2.6-v17"
56+
)
57+
58+
if [[ -v redis_stack_version_mapping[$REDIS_VERSION] ]]; then
59+
export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:${redis_stack_version_mapping[$REDIS_VERSION]}"
60+
else
61+
echo "Version not found in the mapping."
62+
exit 1
63+
fi
64+
65+
if (( redis_major_version < 7 )); then
66+
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
67+
fi
68+
69+
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
70+
else
71+
echo "Using redis CE for module tests"
72+
export CLIENT_LIBS_TEST_IMAGE="redislabs/client-libs-test:$REDIS_VERSION"
73+
docker compose --profile all -f tests/dockers/docker-compose.yml up -d --build
74+
fi
75+
shell: bash
76+
77+
# Make sure only the desired dotnet version is set both as target and as active SDK.
78+
- name: Tweak target frameworks
79+
shell: bash
80+
run: |
81+
find . -name '*.csproj' | xargs -I {} sed -E -i "s|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|" {}
82+
find . -name '*.csproj' | xargs cat
83+
jq -n --arg version ${{inputs.dotnet-version}} '{"sdk":{"version":$version,"rollForward":"latestMinor"}}' > global.json
84+
- name: Check .NET version
85+
shell: bash
86+
run: dotnet --version
87+
- name: Check .NET SDKs
88+
shell: bash
89+
run: dotnet --list-sdks
90+
- name: Check .NET runtimes
91+
shell: bash
92+
run: dotnet --list-runtimes
93+
- name: Restore dependencies
94+
shell: bash
95+
run: dotnet restore
96+
97+
- name: Build
98+
shell: bash
99+
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
100+
101+
- name: Test
102+
shell: bash
103+
run: |
104+
echo "${{inputs.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_ca.pem
105+
echo "${{inputs.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user.crt
106+
echo "${{inputs.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user_private.key
107+
dotnet test -f ${CLR_VERSION} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -p:BuildInParallel=false tests/Test.proj --logger GitHubActions
108+
- name: Codecov
109+
uses: codecov/codecov-action@v4
110+
with:
111+
verbose: true
112+
- name: Build
113+
shell: bash
114+
run: dotnet pack -c Release
115+
116+
- name: Test against Nuget package from local source
117+
if: inputs.verify-nuget-package == 'true'
118+
working-directory: PackageVerification
119+
shell: bash
120+
run: |
121+
mkdir -p test-source
122+
dotnet nuget add source $(readlink -f test-source) -n test-source
123+
find .. -name '*.nupkg' | xargs -I {} dotnet nuget push {} -s test-source
124+
ls -R
125+
dotnet nuget remove source nuget.org
126+
dotnet nuget list source
127+
find . -name '*.csproj' | xargs -I {} sed -E -i 's|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|' {}
128+
dotnet restore -s test-source -v detailed
129+
dotnet run
130+

.github/dockers/Dockerfile.cluster

-7
This file was deleted.

.github/dockers/cluster.redis.conf

-8
This file was deleted.

.github/dockers/create_cluster.sh

-47
This file was deleted.

0 commit comments

Comments
 (0)