Skip to content

Commit 2e4fc0b

Browse files
Fixes state cert tests (#3596)
Signed-off-by: Elena Kolevska <[email protected]>
1 parent 1e095ed commit 2e4fc0b

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

.github/infrastructure/docker-compose-sqlserver.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '3'
22
services:
33
sqlserver:
44
image: mcr.microsoft.com/mssql/server:2019-latest

tests/certification/state/azure/cosmosdb/cosmosdb_test.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,13 @@ func TestAzureCosmosDBStorage(t *testing.T) {
133133
"partitionKey": "mypartition",
134134
}
135135

136-
test := func(setMeta, getMeta map[string]string, expectedValue string, expectedErr bool) {
136+
test := func(setMeta, getMeta map[string]string, expectedValue string) {
137137
// save state, default options: strong, last-write
138138
err = client.SaveState(ctx, statestore, stateKey, []byte(stateValue), setMeta)
139139
require.NoError(t, err)
140140

141141
// get state
142142
item, err := client.GetState(ctx, statestore, stateKey, getMeta)
143-
if expectedErr {
144-
require.Error(t, err)
145-
return
146-
}
147143
require.NoError(t, err)
148144
assert.Equal(t, expectedValue, string(item.Value))
149145

@@ -153,13 +149,13 @@ func TestAzureCosmosDBStorage(t *testing.T) {
153149
}
154150

155151
// Test with no partition key
156-
test(nil, meta1, stateValue, false)
152+
test(nil, meta1, stateValue)
157153

158154
// Test with specific partition key
159-
test(meta2, meta2, stateValue, false)
155+
test(meta2, meta2, stateValue)
160156

161157
// Test with incorrect partition key
162-
test(meta2, meta1, "", true)
158+
test(meta2, meta1, "")
163159

164160
return nil
165161
}

tests/certification/state/memcached/memcached_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ import (
2222
"github.com/dapr/components-contrib/state"
2323
"github.com/dapr/go-sdk/client"
2424

25+
"github.com/stretchr/testify/assert"
26+
"github.com/stretchr/testify/require"
27+
2528
state_memcached "github.com/dapr/components-contrib/state/memcached"
2629
"github.com/dapr/components-contrib/tests/certification/embedded"
2730
"github.com/dapr/components-contrib/tests/certification/flow"
@@ -31,8 +34,6 @@ import (
3134
state_loader "github.com/dapr/dapr/pkg/components/state"
3235
dapr_testing "github.com/dapr/dapr/pkg/testing"
3336
"github.com/dapr/kit/logger"
34-
"github.com/stretchr/testify/assert"
35-
"github.com/stretchr/testify/require"
3637
)
3738

3839
const (
@@ -168,7 +169,7 @@ func TestMemcached(t *testing.T) {
168169
key := certificationTestPrefix + "_expiresInOneSecondKey"
169170
value := "This key will self-destroy in 1 second"
170171

171-
ttlExpirationTime := 1 * time.Second
172+
ttlExpirationTime := 3 * time.Second
172173
ttlInSeconds := int(ttlExpirationTime.Seconds())
173174
mapOptionsExpiringKey := map[string]string{
174175
"ttlInSeconds": strconv.Itoa(ttlInSeconds),

tests/certification/state/sqlserver/sqlserver_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ const (
6060
)
6161

6262
func TestSqlServer(t *testing.T) {
63+
// The default certificate created by the docker container sometimes contains a negative serial number.
64+
// A TLS certificate with a negative serial number is invalid, although it was tolerated until 1.22
65+
// Since Go 1.23 the default behavior has changed and the certificate is rejected.
66+
// This environment variable is used to revert to the old behavior.
67+
// Ref: https://github.com/microsoft/mssql-docker/issues/895
68+
oldDebugValue := os.Getenv("GODEBUG")
69+
err := os.Setenv("GODEBUG", "x509negativeserial=1")
70+
if err != nil {
71+
t.Fatalf("Failed to set GODEBUG environment variable: %v", err)
72+
}
73+
defer func() {
74+
os.Setenv("GODEBUG", oldDebugValue)
75+
}()
76+
6377
ports, err := dapr_testing.GetFreePorts(2)
6478
require.NoError(t, err)
6579

0 commit comments

Comments
 (0)