From 1efaed10d305dd83b2484d87ebd8d64c4caa47b7 Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Sun, 12 Nov 2023 18:29:22 +0000 Subject: [PATCH 01/14] Whietlist dot imports for test packages --- .golangci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 200569a59..9f41c7e19 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -91,6 +91,12 @@ linters-settings: forbid-focus-container: true # Don't trigger warnings for HaveLen(0) allow-havelen-zero: true + stylecheck: + # Whietlist dot imports for test packages. + dot-import-whitelist: + - "github.com/onsi/ginkgo" + - "github.com/onsi/gomega" + - "github.com/0xERR0R/blocky/helpertest" issues: exclude-rules: From 2eaf10fa838ab979f4ef1876293c3cd9be39ba22 Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Sun, 12 Nov 2023 20:16:22 +0000 Subject: [PATCH 02/14] improved generate-lcov script --- .devcontainer/scripts/generate-lcov.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/scripts/generate-lcov.sh b/.devcontainer/scripts/generate-lcov.sh index 7e7675efa..5907338cf 100644 --- a/.devcontainer/scripts/generate-lcov.sh +++ b/.devcontainer/scripts/generate-lcov.sh @@ -2,4 +2,4 @@ cd "${WORKSPACE_FOLDER}" -nohup bash -c 'ginkgo --label-filter="!e2e" --no-color --keep-going --timeout=5m --coverprofile=lcov.work --covermode=set --cover -r -p && gcov2lcov -infile=coverage.txt -outfile=lcov.info' > lcov.log 2>&1 \ No newline at end of file +nohup bash -c 'echo "-- Start tests --" && (ginkgo --label-filter="!e2e" --no-color --keep-going --timeout=5m --coverprofile=lcov.work --covermode=atomic --cover -r -p || true) && echo "-- Start lcov convert --" && gcov2lcov -infile=lcov.work -outfile=lcov.info && echo "-- Finished --"' > lcov.log 2>&1 From 579092580977c57a62f828db006db2711dcdc8a3 Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Sun, 12 Nov 2023 20:31:58 +0000 Subject: [PATCH 03/14] moved mock_call_sequence to helpertest --- {util => helpertest}/mock_call_sequence.go | 2 +- lists/list_cache_test.go | 5 ++--- lists/parsers/parser_test.go | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) rename {util => helpertest}/mock_call_sequence.go (98%) diff --git a/util/mock_call_sequence.go b/helpertest/mock_call_sequence.go similarity index 98% rename from util/mock_call_sequence.go rename to helpertest/mock_call_sequence.go index 7bf122349..567bc1697 100644 --- a/util/mock_call_sequence.go +++ b/helpertest/mock_call_sequence.go @@ -1,4 +1,4 @@ -package util +package helpertest import ( "context" diff --git a/lists/list_cache_test.go b/lists/list_cache_test.go index e39ffbaa9..b677774e0 100644 --- a/lists/list_cache_test.go +++ b/lists/list_cache_test.go @@ -14,7 +14,6 @@ import ( . "github.com/0xERR0R/blocky/evt" "github.com/0xERR0R/blocky/lists/parsers" "github.com/0xERR0R/blocky/log" - "github.com/0xERR0R/blocky/util" "github.com/google/uuid" "github.com/sirupsen/logrus" @@ -449,11 +448,11 @@ var _ = Describe("ListCache", func() { }) type MockDownloader struct { - util.MockCallSequence[string] + MockCallSequence[string] } func newMockDownloader(driver func(res chan<- string, err chan<- error)) *MockDownloader { - return &MockDownloader{util.NewMockCallSequence(driver)} + return &MockDownloader{NewMockCallSequence(driver)} } func (m *MockDownloader) DownloadFile(_ string) (io.ReadCloser, error) { diff --git a/lists/parsers/parser_test.go b/lists/parsers/parser_test.go index 25565f781..85be936a5 100644 --- a/lists/parsers/parser_test.go +++ b/lists/parsers/parser_test.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/0xERR0R/blocky/util" + . "github.com/0xERR0R/blocky/helpertest" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ) @@ -163,10 +163,10 @@ func iteratorToList[T any](forEach func(func(T) error) error) []T { return res } -type mockParser[T any] struct{ util.MockCallSequence[T] } +type mockParser[T any] struct{ MockCallSequence[T] } func newMockParser[T any](driver func(chan<- T, chan<- error)) SeriesParser[T] { - return &mockParser[T]{util.NewMockCallSequence(driver)} + return &mockParser[T]{NewMockCallSequence(driver)} } func (m *mockParser[T]) Next(ctx context.Context) (_ T, rerr error) { From bf01a4ad7eac840c8eda9b85039da3549b8194d3 Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Sun, 12 Nov 2023 20:37:11 +0000 Subject: [PATCH 04/14] removed default config for markdown --- .devcontainer/devcontainer.json | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 51a6be183..1ac0a281e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,14 +17,14 @@ "customizations": { "vscode": { "extensions": [ - "golang.go", - "esbenp.prettier-vscode", - "yzhang.markdown-all-in-one", - "joselitofilho.ginkgotestexplorer", - "fsevenm.run-it-on", - "markis.code-coverage", - "tooltitudeteam.tooltitude" - ], + "golang.go", + "esbenp.prettier-vscode", + "yzhang.markdown-all-in-one", + "joselitofilho.ginkgotestexplorer", + "fsevenm.run-it-on", + "markis.code-coverage", + "tooltitudeteam.tooltitude" + ], "settings": { "go.lintFlags": ["--config=${containerWorkspaceFolder}/.golangci.yml"], "go.alternateTools": { @@ -37,16 +37,7 @@ "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[markdown]": { - "editor.defaultFormatter": "yzhang.markdown-all-in-one", - "editor.unicodeHighlight.ambiguousCharacters": false, - "editor.unicodeHighlight.invisibleCharacters": false, - "diffEditor.ignoreTrimWhitespace": false, - "editor.wordWrap": "on", - "editor.quickSuggestions": { - "comments": "off", - "strings": "off", - "other": "off" - } + "editor.defaultFormatter": "yzhang.markdown-all-in-one" } } } From b5cbb98fdfdb07aab8ef52c2d9e4d6c346958715 Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Mon, 13 Nov 2023 14:51:36 +0000 Subject: [PATCH 05/14] generate seperate lcov.info for each directory --- .devcontainer/scripts/generate-lcov.sh | 5 ---- .devcontainer/scripts/runItOnGo.sh | 34 ++++++++++++++++++++++++++ .dockerignore | 2 ++ .gitignore | 2 +- .vscode/settings.json | 3 +-- 5 files changed, 38 insertions(+), 8 deletions(-) delete mode 100644 .devcontainer/scripts/generate-lcov.sh create mode 100644 .devcontainer/scripts/runItOnGo.sh diff --git a/.devcontainer/scripts/generate-lcov.sh b/.devcontainer/scripts/generate-lcov.sh deleted file mode 100644 index 5907338cf..000000000 --- a/.devcontainer/scripts/generate-lcov.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -e - -cd "${WORKSPACE_FOLDER}" - -nohup bash -c 'echo "-- Start tests --" && (ginkgo --label-filter="!e2e" --no-color --keep-going --timeout=5m --coverprofile=lcov.work --covermode=atomic --cover -r -p || true) && echo "-- Start lcov convert --" && gcov2lcov -infile=lcov.work -outfile=lcov.info && echo "-- Finished --"' > lcov.log 2>&1 diff --git a/.devcontainer/scripts/runItOnGo.sh b/.devcontainer/scripts/runItOnGo.sh new file mode 100644 index 000000000..a955ab365 --- /dev/null +++ b/.devcontainer/scripts/runItOnGo.sh @@ -0,0 +1,34 @@ +#!/bin/bash -e + +FOLDER_PATH=$1 +if [ -z "${FOLDER_PATH}" ]; then + FOLDER_PATH=$PWD +fi + +BASE_PATH=$2 +if [ -z "${BASE_PATH}" ]; then + BASE_PATH=$WORKSPACE_FOLDER +fi + +if [ "$FOLDER_PATH" = "$BASE_PATH" ]; then + echo "Skipping lcov creation for base path" + exit 1 +fi + +FOLDER_NAME=${FOLDER_PATH#"$BASE_PATH/"} +FILE_NAME="$(echo "$FOLDER_NAME" | sed 's/\//-/g').ginkgo" +FILE_PATH="/tmp/$FILE_NAME" + + +echo "-- Start $FOLDER_NAME ($(date '+%T')) --" + +TIMEFORMAT=' - Ginkgo tests finished in: %R seconds' +time ginkgo --label-filter="!e2e" --keep-going --timeout=5m --output-dir=/tmp --coverprofile="$FILE_NAME" --covermode=atomic --cover -r -p || true + +TIMEFORMAT=' - lcov convert finished in: %R seconds' +time gcov2lcov -infile="$FILE_PATH" -outfile="$FOLDER_PATH/lcov.info" + +TIMEFORMAT=' - cleanup finished in: %R seconds' +time rm "$FILE_PATH" + +echo "-- Finished ($(date '+%T')) --" \ No newline at end of file diff --git a/.dockerignore b/.dockerignore index b46a022a5..6e5bc54c1 100644 --- a/.dockerignore +++ b/.dockerignore @@ -12,3 +12,5 @@ LICENSE vendor e2e/ .devcontainer/ +coverage.txt +lcov.info diff --git a/.gitignore b/.gitignore index df8b9c970..2e088e09d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ node_modules package-lock.json vendor/ coverage.txt -lcov.* \ No newline at end of file +lcov.info diff --git a/.vscode/settings.json b/.vscode/settings.json index 1f22d135c..0e6020812 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,8 +23,7 @@ "commands": [ { "match": "\\.go$", - "cmd": "./.devcontainer/scripts/generate-lcov.sh", - "silent": true + "cmd": "${workspaceRoot}/.devcontainer/scripts/runItOnGo.sh ${fileDirname} ${workspaceRoot}" } ] } From dc0f92eefa986ecc8115feef97d96792fb6bd942 Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Mon, 13 Nov 2023 14:57:11 +0000 Subject: [PATCH 06/14] path fix in lcov generation script --- .devcontainer/scripts/runItOnGo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/scripts/runItOnGo.sh b/.devcontainer/scripts/runItOnGo.sh index a955ab365..37f4adb2a 100644 --- a/.devcontainer/scripts/runItOnGo.sh +++ b/.devcontainer/scripts/runItOnGo.sh @@ -23,7 +23,7 @@ FILE_PATH="/tmp/$FILE_NAME" echo "-- Start $FOLDER_NAME ($(date '+%T')) --" TIMEFORMAT=' - Ginkgo tests finished in: %R seconds' -time ginkgo --label-filter="!e2e" --keep-going --timeout=5m --output-dir=/tmp --coverprofile="$FILE_NAME" --covermode=atomic --cover -r -p || true +time ginkgo --label-filter="!e2e" --keep-going --timeout=5m --output-dir=/tmp --coverprofile="$FILE_NAME" --covermode=atomic --cover -r -p "$FOLDER_PATH" || true TIMEFORMAT=' - lcov convert finished in: %R seconds' time gcov2lcov -infile="$FILE_PATH" -outfile="$FOLDER_PATH/lcov.info" From 668be0514587ecefe51d8a00f2b76979fa607fbf Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Mon, 13 Nov 2023 14:59:26 +0000 Subject: [PATCH 07/14] ginkgo -> v2.13.1 --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 03e27d3f7..3369d1eef 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect github.com/miekg/dns v1.1.56 github.com/mroth/weightedrand/v2 v2.1.0 - github.com/onsi/ginkgo/v2 v2.13.0 + github.com/onsi/ginkgo/v2 v2.13.1 github.com/onsi/gomega v1.30.0 github.com/prometheus/client_golang v1.17.0 github.com/sirupsen/logrus v1.9.3 @@ -64,7 +64,7 @@ require ( github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/go-units v0.5.0 // indirect github.com/getkin/kin-openapi v0.118.0 // indirect - github.com/go-logr/logr v1.2.4 // indirect + github.com/go-logr/logr v1.3.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/pprof v0.0.0-20230309165930-d61513b1440d // indirect diff --git a/go.sum b/go.sum index 2dffe33e4..d6ec3fb68 100644 --- a/go.sum +++ b/go.sum @@ -92,8 +92,8 @@ github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk= github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= -github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= -github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= @@ -231,8 +231,8 @@ github.com/oapi-codegen/runtime v1.0.0 h1:P4rqFX5fMFWqRzY9M/3YF9+aPSPPB06IzP2P7o github.com/oapi-codegen/runtime v1.0.0/go.mod h1:LmCUMQuPB4M/nLXilQXhHw+BLZdDb18B34OO356yJ/A= github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= -github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU= +github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM= github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8= github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= From f002c8a6774147eb4267389fd107519f32240b6e Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Mon, 13 Nov 2023 15:09:26 +0000 Subject: [PATCH 08/14] fixed redundant strings --- server/server_test.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/server/server_test.go b/server/server_test.go index 8943e1915..12c27aadd 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -39,11 +39,13 @@ var ( sut *Server err error baseURL string + queryURL string googleMockUpstream, fritzboxMockUpstream, clientMockUpstream *resolver.MockUDPUpstreamServer ) var _ = BeforeSuite(func() { baseURL = "http://localhost:" + GetStringPort(httpBasePort) + "/" + queryURL = baseURL + "dns-query" var upstreamGoogle, upstreamFritzbox, upstreamClient config.Upstream ctx, cancelFn := context.WithCancel(context.Background()) DeferCleanup(cancelFn) @@ -415,7 +417,7 @@ var _ = Describe("Running DNS server", func() { Context("DOH over GET (RFC 8484)", func() { When("DOH get request with 'example.com' is performed", func() { It("should get a valid response", func() { - resp, err := http.Get(baseURL + "dns-query?dns=AAABAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB") + resp, err := http.Get(queryURL + "?dns=AAABAAABAAAAAAAAA3d3dwdleGFtcGxlA2NvbQAAAQAB") Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -434,7 +436,7 @@ var _ = Describe("Running DNS server", func() { }) When("Request does not contain a valid DNS message", func() { It("should return 'Bad Request'", func() { - resp, err := http.Get(baseURL + "dns-query?dns=xxxx") + resp, err := http.Get(queryURL + "?dns=xxxx") Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -443,7 +445,7 @@ var _ = Describe("Running DNS server", func() { }) When("Request's parameter does not contain a valid base64'", func() { It("should return 'Bad Request'", func() { - resp, err := http.Get(baseURL + "dns-query?dns=äöä") + resp, err := http.Get(queryURL + "?dns=äöä") Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -452,7 +454,7 @@ var _ = Describe("Running DNS server", func() { }) When("Request does not contain a dns parameter", func() { It("should return 'Bad Request'", func() { - resp, err := http.Get(baseURL + "dns-query?test") + resp, err := http.Get(queryURL + "?test") Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -463,7 +465,7 @@ var _ = Describe("Running DNS server", func() { It("should return 'URI Too Long'", func() { longBase64msg := base64.StdEncoding.EncodeToString([]byte(strings.Repeat("t", 513))) - resp, err := http.Get(baseURL + "dns-query?dns=" + longBase64msg) + resp, err := http.Get(queryURL + "?dns=" + longBase64msg) Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -482,7 +484,7 @@ var _ = Describe("Running DNS server", func() { rawDNSMessage, err := msg.Pack() Expect(err).Should(Succeed()) - resp, err = http.Post(baseURL+"dns-query", + resp, err = http.Post(queryURL, "application/dns-message", bytes.NewReader(rawDNSMessage)) Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -507,7 +509,7 @@ var _ = Describe("Running DNS server", func() { rawDNSMessage, err := msg.Pack() Expect(err).Should(Succeed()) - resp, err = http.Post(baseURL+"dns-query/client123", + resp, err = http.Post(queryURL+"/client123", "application/dns-message", bytes.NewReader(rawDNSMessage)) Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -531,7 +533,7 @@ var _ = Describe("Running DNS server", func() { It("should return 'Payload Too Large'", func() { largeMessage := []byte(strings.Repeat("t", 513)) - resp, err = http.Post(baseURL+"dns-query", "application/dns-message", bytes.NewReader(largeMessage)) + resp, err = http.Post(queryURL, "application/dns-message", bytes.NewReader(largeMessage)) Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -540,7 +542,7 @@ var _ = Describe("Running DNS server", func() { }) When("Request has wrong type", func() { It("should return 'Unsupported Media Type'", func() { - resp, err = http.Post(baseURL+"dns-query", "application/text", bytes.NewReader([]byte("a"))) + resp, err = http.Post(queryURL, "application/text", bytes.NewReader([]byte("a"))) Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) @@ -553,7 +555,7 @@ var _ = Describe("Running DNS server", func() { rawDNSMessage, err := msg.Pack() Expect(err).Should(Succeed()) - resp, err = http.Post(baseURL+"dns-query", + resp, err = http.Post(queryURL, "application/dns-message", bytes.NewReader(rawDNSMessage)) Expect(err).Should(Succeed()) DeferCleanup(resp.Body.Close) From adbf050b8d1ba672f32ec8e485b4ab67bcee3cea Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Mon, 13 Nov 2023 17:54:42 +0000 Subject: [PATCH 09/14] added exampleComKey --- redis/redis_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/redis/redis_test.go b/redis/redis_test.go index 9ddf6185d..04efb6b76 100644 --- a/redis/redis_test.go +++ b/redis/redis_test.go @@ -14,6 +14,10 @@ import ( . "github.com/onsi/gomega" ) +const ( + exampleComKey = CacheStorePrefix + "example.com" +) + var ( redisServer *miniredis.Miniredis redisClient *Client @@ -100,10 +104,10 @@ var _ = Describe("Redis client", func() { By("Database has one entry with correct TTL", func() { Eventually(func() bool { - return redisServer.DB(redisConfig.Database).Exists(CacheStorePrefix + "example.com") + return redisServer.DB(redisConfig.Database).Exists(exampleComKey) }).Should(BeTrue()) - ttl := redisServer.DB(redisConfig.Database).TTL(CacheStorePrefix + "example.com") + ttl := redisServer.DB(redisConfig.Database).TTL(exampleComKey) Expect(ttl.Seconds()).Should(BeNumerically("~", 123)) }) }) @@ -125,10 +129,10 @@ var _ = Describe("Redis client", func() { By("Database has one entry with default TTL", func() { Eventually(func() bool { - return redisServer.DB(redisConfig.Database).Exists(CacheStorePrefix + "example.com") + return redisServer.DB(redisConfig.Database).Exists(exampleComKey) }).Should(BeTrue()) - ttl := redisServer.DB(redisConfig.Database).TTL(CacheStorePrefix + "example.com") + ttl := redisServer.DB(redisConfig.Database).TTL(exampleComKey) Expect(ttl.Seconds()).Should(BeNumerically("~", defaultCacheTime.Seconds())) }) }) From b506b3642018820df4c979f845d5d2a0cdec1259 Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Mon, 13 Nov 2023 17:57:47 +0000 Subject: [PATCH 10/14] added folder name to finish message --- .devcontainer/scripts/runItOnGo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/scripts/runItOnGo.sh b/.devcontainer/scripts/runItOnGo.sh index 37f4adb2a..fa48592c4 100644 --- a/.devcontainer/scripts/runItOnGo.sh +++ b/.devcontainer/scripts/runItOnGo.sh @@ -31,4 +31,4 @@ time gcov2lcov -infile="$FILE_PATH" -outfile="$FOLDER_PATH/lcov.info" TIMEFORMAT=' - cleanup finished in: %R seconds' time rm "$FILE_PATH" -echo "-- Finished ($(date '+%T')) --" \ No newline at end of file +echo "-- Finished $FOLDER_NAME ($(date '+%T')) --" \ No newline at end of file From 228efd51bc4895acbd08278b78b37fd0db67167e Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Tue, 14 Nov 2023 18:24:51 +0000 Subject: [PATCH 11/14] hide lcov.info in devcontainer --- .devcontainer/devcontainer.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1ac0a281e..d06aaa711 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -26,6 +26,9 @@ "tooltitudeteam.tooltitude" ], "settings": { + "files.exclude": { + "**/lcov.info": true + }, "go.lintFlags": ["--config=${containerWorkspaceFolder}/.golangci.yml"], "go.alternateTools": { "go-langserver": "gopls" From ffb77a6a54d252e851e2e0d572a0d454338822dd Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Tue, 14 Nov 2023 19:31:27 +0000 Subject: [PATCH 12/14] coverage plugin is bugged if lcov file is excluded --- .devcontainer/devcontainer.json | 3 --- .vscode/settings.json | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index d06aaa711..1ac0a281e 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -26,9 +26,6 @@ "tooltitudeteam.tooltitude" ], "settings": { - "files.exclude": { - "**/lcov.info": true - }, "go.lintFlags": ["--config=${containerWorkspaceFolder}/.golangci.yml"], "go.alternateTools": { "go-langserver": "gopls" diff --git a/.vscode/settings.json b/.vscode/settings.json index 0e6020812..2c4b6ccb2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,5 +26,6 @@ "cmd": "${workspaceRoot}/.devcontainer/scripts/runItOnGo.sh ${fileDirname} ${workspaceRoot}" } ] - } + }, + "markiscodecoverage.searchCriteria": "**/lcov.info" } From 50344fb4c90058584f93db39bb37efea0d449dbc Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Wed, 15 Nov 2023 15:17:12 +0000 Subject: [PATCH 13/14] moved all lcov files to coverage folder --- .devcontainer/devcontainer.json | 9 +++++++++ .devcontainer/scripts/runItOnGo.sh | 15 ++++++++++----- .dockerignore | 2 +- .gitignore | 2 +- .vscode/settings.json | 11 +---------- 5 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1ac0a281e..b15db0ee6 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -38,6 +38,15 @@ }, "[markdown]": { "editor.defaultFormatter": "yzhang.markdown-all-in-one" + }, + "markiscodecoverage.searchCriteria": "**/*.lcov", + "runItOn": { + "commands": [ + { + "match": "\\.go$", + "cmd": "${workspaceRoot}/.devcontainer/scripts/runItOnGo.sh ${fileDirname} ${workspaceRoot}" + } + ] } } } diff --git a/.devcontainer/scripts/runItOnGo.sh b/.devcontainer/scripts/runItOnGo.sh index fa48592c4..ce57fe93d 100644 --- a/.devcontainer/scripts/runItOnGo.sh +++ b/.devcontainer/scripts/runItOnGo.sh @@ -16,19 +16,24 @@ if [ "$FOLDER_PATH" = "$BASE_PATH" ]; then fi FOLDER_NAME=${FOLDER_PATH#"$BASE_PATH/"} -FILE_NAME="$(echo "$FOLDER_NAME" | sed 's/\//-/g').ginkgo" -FILE_PATH="/tmp/$FILE_NAME" +WORK_NAME="$(echo "$FOLDER_NAME" | sed 's/\//-/g')" +WORK_FILE_NAME="$WORK_NAME.ginkgo" +WORK_FILE_PATH="/tmp/$WORK_FILE_NAME" +OUTPUT_FOLDER="$BASE_PATH/coverage" +OUTPUT_FILE_PATH="$OUTPUT_FOLDER/$WORK_NAME.lcov" +mkdir -p "$OUTPUT_FOLDER" + echo "-- Start $FOLDER_NAME ($(date '+%T')) --" TIMEFORMAT=' - Ginkgo tests finished in: %R seconds' -time ginkgo --label-filter="!e2e" --keep-going --timeout=5m --output-dir=/tmp --coverprofile="$FILE_NAME" --covermode=atomic --cover -r -p "$FOLDER_PATH" || true +time ginkgo --label-filter="!e2e" --keep-going --timeout=5m --output-dir=/tmp --coverprofile="$WORK_FILE_NAME" --covermode=atomic --cover -r -p "$FOLDER_PATH" || true TIMEFORMAT=' - lcov convert finished in: %R seconds' -time gcov2lcov -infile="$FILE_PATH" -outfile="$FOLDER_PATH/lcov.info" +time gcov2lcov -infile="$WORK_FILE_PATH" -outfile="$OUTPUT_FILE_PATH" || true TIMEFORMAT=' - cleanup finished in: %R seconds' -time rm "$FILE_PATH" +time rm "$WORK_FILE_PATH" || true echo "-- Finished $FOLDER_NAME ($(date '+%T')) --" \ No newline at end of file diff --git a/.dockerignore b/.dockerignore index 6e5bc54c1..8468acd47 100644 --- a/.dockerignore +++ b/.dockerignore @@ -13,4 +13,4 @@ vendor e2e/ .devcontainer/ coverage.txt -lcov.info +coverage/ diff --git a/.gitignore b/.gitignore index 2e088e09d..e63218cda 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,4 @@ node_modules package-lock.json vendor/ coverage.txt -lcov.info +coverage/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 2c4b6ccb2..a1acd12ea 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -18,14 +18,5 @@ "ui.semanticTokens": true, "formatting.gofumpt": true, "build.standaloneTags": ["ignore", "tools"] - }, - "runItOn": { - "commands": [ - { - "match": "\\.go$", - "cmd": "${workspaceRoot}/.devcontainer/scripts/runItOnGo.sh ${fileDirname} ${workspaceRoot}" - } - ] - }, - "markiscodecoverage.searchCriteria": "**/lcov.info" + } } From 8e2e024b29b334680df31d06d09a6e348f9d304e Mon Sep 17 00:00:00 2001 From: Kwitsch Date: Wed, 15 Nov 2023 15:28:33 +0000 Subject: [PATCH 14/14] added requested toos #1251 --- .devcontainer/devcontainer.json | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b15db0ee6..e055204fe 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,11 @@ "ghcr.io/devcontainers/features/docker-in-docker:2": { "dockerDashComposeVersion": "v2" }, - "ghcr.io/devcontainers/features/python:1": {} + "ghcr.io/devcontainers/features/python:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": { + "packages": "dnsutils " + } }, "remoteEnv": { "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}", @@ -26,7 +30,9 @@ "tooltitudeteam.tooltitude" ], "settings": { - "go.lintFlags": ["--config=${containerWorkspaceFolder}/.golangci.yml"], + "go.lintFlags": [ + "--config=${containerWorkspaceFolder}/.golangci.yml" + ], "go.alternateTools": { "go-langserver": "gopls" }, @@ -58,4 +64,4 @@ ], "postCreateCommand": "sudo chmod +x .devcontainer/scripts/*.sh", "postStartCommand": "sh .devcontainer/scripts/postStart.sh" -} +} \ No newline at end of file