Skip to content

Commit c2b4a9a

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
1 parent 15fd7d2 commit c2b4a9a

File tree

86 files changed

+2429
-2655
lines changed

Some content is hidden

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

86 files changed

+2429
-2655
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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"]="7.4.0-v1"
54+
["7.2.6"]="7.2.0-v13"
55+
["6.2.16"]="6.2.6-v17"
56+
)
57+
58+
if [[ -v redis_stack_version_mapping[$REDIS_VERSION] ]]; then
59+
export REDIS_STACK_IMAGE="redis/redis-stack-server:${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_STACK_EXTRA_ARGS="--tls-auth-clients optional --save ''"
67+
export REDIS_EXTRA_ARGS="--tls-auth-clients optional --save ''"
68+
fi
69+
else
70+
echo "Using redis CE for module tests"
71+
fi
72+
73+
docker compose -f tests/dockers/docker-compose.yml up -d
74+
shell: bash
75+
76+
# Make sure only the desired dotnet version is set both as target and as active SDK.
77+
- name: Tweak target frameworks
78+
run: |
79+
find . -name '*.csproj' | xargs -I {} sed -E -i 's|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|' {}
80+
find . -name '*.csproj' | xargs cat
81+
jq -n --arg version ${{inputs.dotnet-version}} '{"sdk":{"version":$version,"rollForward":"latestMinor"}}' > global.json
82+
- name: Check .NET version
83+
run: dotnet --version
84+
- name: Check .NET SDKs
85+
run: dotnet --list-sdks
86+
- name: Check .NET runtimes
87+
run: dotnet --list-runtimes
88+
- name: Restore dependencies
89+
run: dotnet restore
90+
91+
- name: Build
92+
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
93+
94+
- name: Test
95+
run: |
96+
echo "${{inputs.REDIS_CA_PEM}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_ca.pem
97+
echo "${{inputs.REDIS_USER_CRT}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user.crt
98+
echo "${{inputs.REDIS_USER_PRIVATE_KEY}}" > tests/NRedisStack.Tests/bin/Debug/${CLR_VERSION}/redis_user_private.key
99+
dotnet test -f ${CLR_VERSION} --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -p:BuildInParallel=false tests/Test.proj --logger GitHubActions
100+
- name: Codecov
101+
uses: codecov/codecov-action@v4
102+
with:
103+
verbose: true
104+
- name: Build
105+
run: dotnet pack -c Release
106+
107+
- name: Test against Nuget package from local source
108+
if: inputs.verify-nuget-package == 'true'
109+
working-directory: PackageVerification
110+
run: |
111+
mkdir -p test-source
112+
dotnet nuget add source $(readlink -f test-source) -n test-source
113+
find .. -name '*.nupkg' | xargs -I {} dotnet nuget push {} -s test-source
114+
ls -R
115+
dotnet nuget remove source nuget.org
116+
dotnet nuget list source
117+
find . -name '*.csproj' | xargs -I {} sed -E -i 's|<TargetFrameworks(.*)>.*</TargetFrameworks>|<TargetFramework\1>${CLR_VERSION}</TargetFramework>|' {}
118+
dotnet restore -s test-source -v detailed
119+
dotnet run
120+

.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.

.github/workflows/modes/.env.enterprise

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

.github/workflows/modes/.env.enterprise_oss_cluster

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

.github/workflows/modes/.env.oss_cluster

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

.github/workflows/modes/.env.standalone

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/Doc/Bf_tutorial.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ namespace Doc;
1515
// HIDE_START
1616
public class Bf_tutorial
1717
{
18-
19-
[SkipIfRedis(Is.OSSCluster)]
18+
2019
public void run()
2120
{
2221
var muxer = ConnectionMultiplexer.Connect("localhost:6379");

tests/Doc/Bitmap_tutorial.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ namespace Doc;
1414
// HIDE_START
1515
public class Bitmap_tutorial
1616
{
17-
18-
[SkipIfRedis(Is.OSSCluster)]
17+
1918
public void run()
2019
{
2120
var muxer = ConnectionMultiplexer.Connect("localhost:6379");

0 commit comments

Comments
 (0)