44 "context"
55 "fmt"
66 "math/big"
7+ "os"
78 "testing"
89 "time"
910
@@ -22,7 +23,35 @@ import (
2223 "google.golang.org/grpc"
2324)
2425
25- func makeClient () (* rocsp.WritingClient , clock.Clock ) {
26+ func makeClient () (* rocsp.RWClient , clock.Clock ) {
27+ CACertFile := "../../test/redis-tls/minica.pem"
28+ CertFile := "../../test/redis-tls/boulder/cert.pem"
29+ KeyFile := "../../test/redis-tls/boulder/key.pem"
30+ tlsConfig := cmd.TLSConfig {
31+ CACertFile : & CACertFile ,
32+ CertFile : & CertFile ,
33+ KeyFile : & KeyFile ,
34+ }
35+ tlsConfig2 , err := tlsConfig .Load ()
36+ if err != nil {
37+ panic (err )
38+ }
39+
40+ rdb := redis .NewRing (& redis.RingOptions {
41+ Addrs : map [string ]string {
42+ "shard1" : "10.33.33.8:4218" ,
43+ "shard2" : "10.33.33.9:4218" ,
44+ },
45+ Username : "unittest-rw" ,
46+ Password : "824968fa490f4ecec1e52d5e34916bdb60d45f8d" ,
47+ TLSConfig : tlsConfig2 ,
48+ })
49+ clk := clock .NewFake ()
50+ return rocsp .NewWritingClient (rdb , 500 * time .Millisecond , clk , metrics .NoopRegisterer ), clk
51+ }
52+
53+ // TODO(#6517) remove this helper.
54+ func makeClusterClient () (* rocsp.CRWClient , clock.Clock ) {
2655 CACertFile := "../../test/redis-tls/minica.pem"
2756 CertFile := "../../test/redis-tls/boulder/cert.pem"
2857 KeyFile := "../../test/redis-tls/boulder/key.pem"
@@ -43,7 +72,8 @@ func makeClient() (*rocsp.WritingClient, clock.Clock) {
4372 TLSConfig : tlsConfig2 ,
4473 })
4574 clk := clock .NewFake ()
46- return rocsp .NewWritingClient (rdb , 500 * time .Millisecond , clk , metrics .NoopRegisterer ), clk
75+
76+ return rocsp .NewClusterWritingClient (rdb , 5 * time .Second , clk , metrics .NoopRegisterer ), clk
4777}
4878
4979func TestGetStartingID (t * testing.T ) {
@@ -79,7 +109,14 @@ func TestGetStartingID(t *testing.T) {
79109}
80110
81111func TestStoreResponse (t * testing.T ) {
82- redisClient , clk := makeClient ()
112+ // TODO(#6517) remove this block.
113+ var redisClient rocsp.Writer
114+ var clk clock.Clock
115+ if os .Getenv ("BOULDER_CONFIG_DIR" ) == "test/config" {
116+ redisClient , clk = makeClusterClient ()
117+ } else {
118+ redisClient , clk = makeClient ()
119+ }
83120
84121 issuer , err := core .LoadCert ("../../test/hierarchy/int-e1.cert.pem" )
85122 test .AssertNotError (t , err , "loading int-e1" )
@@ -116,7 +153,14 @@ func (mog mockOCSPGenerator) GenerateOCSP(ctx context.Context, in *capb.Generate
116153}
117154
118155func TestLoadFromDB (t * testing.T ) {
119- redisClient , clk := makeClient ()
156+ // TODO(#6517) remove this block.
157+ var redisClient rocsp.Writer
158+ var clk clock.Clock
159+ if os .Getenv ("BOULDER_CONFIG_DIR" ) == "test/config" {
160+ redisClient , clk = makeClusterClient ()
161+ } else {
162+ redisClient , clk = makeClient ()
163+ }
120164
121165 dbMap , err := sa .NewDbMap (vars .DBConnSA , sa.DbSettings {})
122166 if err != nil {
0 commit comments