From 77a5ae48c77d26a9cf0da07a65f65b6dcf2fdfbe Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Wed, 15 Nov 2023 11:57:54 +0800 Subject: [PATCH] update files --- azure-pipelines.yml | 46 ++++++++++++++++++++++++++++ codecov.yml | 3 ++ docfx.json | 63 ++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 40 ++++++++++++++++++++++++ env/redis.conf | 68 +++++++++++++++++++++++++++++++++++++++++ env/sentinel.conf | 8 +++++ scripts/build.sh | 4 +++ scripts/test.sh | 33 ++++++++++++++++++++ scripts/up_converage.sh | 5 +++ 9 files changed, 270 insertions(+) create mode 100644 azure-pipelines.yml create mode 100644 codecov.yml create mode 100644 docfx.json create mode 100644 docker-compose.yml create mode 100644 env/redis.conf create mode 100644 env/sentinel.conf create mode 100644 scripts/build.sh create mode 100644 scripts/test.sh create mode 100644 scripts/up_converage.sh diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..1bc08dbe --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,46 @@ +jobs: + - job: build_and_run_ut_by_linux + displayName: Build and Run Unit Test By (Ubuntu:Latest) + timeoutInMinutes: 120 + pool: + vmImage: ubuntu-latest + steps: + - task: DockerCompose@0 + displayName: "Deploy Docker Compose" + inputs: + action: 'Run a Docker Compose command' + containerregistrytype: 'Container Registry' + dockerComposeFile: '$(Build.SourcesDirectory)/docker-compose.yml' + dockerComposeFileArgs: | + workDirectory=$(Build.SourcesDirectory) + dockerComposeCommand: up -d + - task: UseDotNet@2 + displayName: "Install .NET Core SDK" + inputs: + version: 5.0.100 + - task: UseDotNet@2 + displayName: "Install .NET Core SDK" + inputs: + version: 3.1.403 + - script: bash scripts/build.sh + displayName: "Build" + - script: bash scripts/test.sh + displayName: "Run Unit Test" + - task: Palmmedia.reportgenerator.reportgenerator-build-release-task.reportgenerator@4 + displayName: ReportGenerator + inputs: + reports: "$(Build.SourcesDirectory)/test/Unit/*/TestResults/*/coverage.cobertura.xml" + targetdir: "$(Build.SourcesDirectory)/CodeCoverage" + reporttypes: "Cobertura" + assemblyfilters: "-xunit*" + - script: bash <(curl -s https://codecov.io/bash) + displayName: "Upload to codecov.io" + - task: DockerCompose@0 + displayName : "Down Docker Compose" + inputs: + action: 'Run a Docker Compose command' + containerregistrytype: 'Container Registry' + dockerComposeFile: '$(Build.SourcesDirectory)/docker-compose.yml' + dockerComposeFileArgs: | + workDirectory=$(Build.SourcesDirectory) + dockerComposeCommand: down --remove-orphans diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 00000000..23be4053 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,3 @@ +codecov: + notify: + after_n_builds: 1 \ No newline at end of file diff --git a/docfx.json b/docfx.json new file mode 100644 index 00000000..00da1ab0 --- /dev/null +++ b/docfx.json @@ -0,0 +1,63 @@ +{ + "metadata": [ + { + "src": [ + { + "files": [ + "src/**/*.cs" + ], + "exclude": [ "**/bin/**", "**/obj/**" ] + } + ], + "dest": "docs/api", + "disableGitFeatures": false, + "disableDefaultFilter": false + } + ], + "build": { + "content": [ + { + "files": [ + "docs/ReleaseNotes.md", + "docs/articles/**.md", + "docs/articles/**/toc.yml", + "docs/api/**.md", + "docs/api/**.yml", + "docs/api/**/toc.yml", + "toc.yml", + "*.md" + ] + } + ], + "resource": [ + { + "files": [ + "docs/**/images/**" + ] + } + ], + "overwrite": [ + { + "files": [ + "docs/api/*.md" + ], + "exclude": [ + "obj/**", + "_site/**" + ] + } + ], + "dest": "_site", + "globalMetadataFiles": [], + "fileMetadataFiles": [], + "template": [ + "default" + ], + "postProcessors": [], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..5be4197d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: "3.9" +services: + redis_single: + image: redis:6.0-alpine + hostname: "redis_single" + container_name: "redis_single" + volumes: + - ${workDirectory}/env/redis.conf:/usr/local/etc/redis/redis.conf + ports: + - "6379:6379" + command: ["redis-server", "/usr/local/etc/redis/redis.conf"] + redis_interceptor: + image: redis:6.0-alpine + hostname: "redis_interceptor" + container_name: "redis_interceptor" + ports: + - "6479:6379" + command: ["redis-server"] + redis_flush: + image: redis:6.0-alpine + hostname: "redis_flush" + container_name: "redis_flush" + ports: + - "6279:6379" + command: ["redis-server"] + redis_master: + image: redis:6.0-alpine + hostname: "redis_master" + container_name: "redis_master" + ports: + - 6380:6379 + redis_sentinel: + image: redis:6.0-alpine + hostname: "redis_sentinel" + container_name: "redis_sentinel" + ports: + - 26379:26379 + command: redis-sentinel /usr/local/etc/redis/sentinel.conf + volumes: + - ${workDirectory}/env/sentinel.conf:/usr/local/etc/redis/sentinel.conf \ No newline at end of file diff --git a/env/redis.conf b/env/redis.conf new file mode 100644 index 00000000..0a2370f4 --- /dev/null +++ b/env/redis.conf @@ -0,0 +1,68 @@ +protected-mode no +tcp-backlog 511 +timeout 0 +tcp-keepalive 300 +daemonize no +supervised no +pidfile /var/run/redis_6379.pid +loglevel notice +logfile "" +databases 16 +always-show-logo yes +save 900 1 +save 300 10 +save 60 10000 +stop-writes-on-bgsave-error yes +rdbcompression yes +rdbchecksum yes +dbfilename dump.rdb +rdb-del-sync-files no +dir ./ +replica-serve-stale-data yes +replica-read-only yes +repl-diskless-sync no +repl-diskless-sync-delay 5 +repl-diskless-load disabled +repl-disable-tcp-nodelay no +replica-priority 100 +acllog-max-len 128 +requirepass 123456 +lazyfree-lazy-eviction no +lazyfree-lazy-expire no +lazyfree-lazy-server-del no +replica-lazy-flush no +lazyfree-lazy-user-del no +oom-score-adj no +oom-score-adj-values 0 200 800 +appendonly no +appendfilename "appendonly.aof" +appendfsync everysec +no-appendfsync-on-rewrite no +auto-aof-rewrite-percentage 100 +auto-aof-rewrite-min-size 64mb +aof-load-truncated yes +aof-use-rdb-preamble yes +lua-time-limit 5000 +slowlog-log-slower-than 10000 +slowlog-max-len 128 +latency-monitor-threshold 0 +notify-keyspace-events "" +hash-max-ziplist-entries 512 +hash-max-ziplist-value 64 +list-max-ziplist-size -2 +list-compress-depth 0 +set-max-intset-entries 512 +zset-max-ziplist-entries 128 +zset-max-ziplist-value 64 +hll-sparse-max-bytes 3000 +stream-node-max-bytes 4096 +stream-node-max-entries 100 +activerehashing yes +client-output-buffer-limit normal 0 0 0 +client-output-buffer-limit replica 256mb 64mb 60 +client-output-buffer-limit pubsub 32mb 8mb 60 +hz 10 +dynamic-hz yes +aof-rewrite-incremental-fsync yes +rdb-save-incremental-fsync yes +jemalloc-bg-thread yes \ No newline at end of file diff --git a/env/sentinel.conf b/env/sentinel.conf new file mode 100644 index 00000000..9bc1d19f --- /dev/null +++ b/env/sentinel.conf @@ -0,0 +1,8 @@ +port 26379 +dir /tmp +sentinel monitor mymaster redis_master 6379 2 +sentinel auth-pass mymaster redis_pwd +sentinel down-after-milliseconds mymaster 30000 +sentinel parallel-syncs mymaster 1 +sentinel failover-timeout mymaster 180000 +sentinel deny-scripts-reconfig yes \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 00000000..d04af297 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash +dotnet sln remove examples/* +dotnet restore -v quiet "FreeRedis.sln" +dotnet build /clp:ErrorsOnly -v quiet "FreeRedis.sln" \ No newline at end of file diff --git a/scripts/test.sh b/scripts/test.sh new file mode 100644 index 00000000..8b77419d --- /dev/null +++ b/scripts/test.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +while read name _ _ _ _ ports; do + key="DOCKER_HOST_$name" + # 0.0.0.0:1234->9876/tcp,first + tempPort=$(cut -d'-' -f1 <<<"$ports") + vr="$key=$tempPort" + echo "$vr" + export "$vr" +done <<<$(docker-compose -p tomatopunk/FreeRedis ps --filter "State="up"" | awk 'FNR > 2') + +#echo $(printenv DOCKER_HOST_redis_auth) +#echo $(printenv DOCKER_HOST_redis_single) + +echo "setup is finished" + +cd test/Unit/ || exit + +for i in *.Tests; do + echo "### Executing Tests for $i:" + + time dotnet test "$i" --no-build \ + --collect:"XPlat Code Coverage" \ + -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByFile="examples/*" \ + >/tmp/freeredis-test.log + + if [[ $? -ne 0 ]]; then + echo "Test Run Failed." + cat /tmp/freeredis-test.log + exit 1 + fi + echo "Test Run Successful." +done diff --git a/scripts/up_converage.sh b/scripts/up_converage.sh new file mode 100644 index 00000000..a82cbd10 --- /dev/null +++ b/scripts/up_converage.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +curl -s https://codecov.io/bash > codecov +chmod +x codecov +./codecov -f "$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml" -t $1 \ No newline at end of file