1
- package replica_test
1
+ package replicasync_test
2
2
3
3
import (
4
4
"context"
@@ -17,7 +17,7 @@ import (
17
17
"cdr.dev/slog/sloggers/slogtest"
18
18
"github.com/coder/coder/coderd/database"
19
19
"github.com/coder/coder/coderd/database/dbtestutil"
20
- "github.com/coder/coder/enterprise/highavailability/replica "
20
+ "github.com/coder/coder/enterprise/highavailability/replicasync "
21
21
"github.com/coder/coder/testutil"
22
22
)
23
23
@@ -32,12 +32,12 @@ func TestReplica(t *testing.T) {
32
32
t .Parallel ()
33
33
db , pubsub := dbtestutil .NewDB (t )
34
34
id := uuid .New ()
35
- cancel , err := pubsub .Subscribe (replica .PubsubEvent , func (ctx context.Context , message []byte ) {
35
+ cancel , err := pubsub .Subscribe (replicasync .PubsubEvent , func (ctx context.Context , message []byte ) {
36
36
assert .Equal (t , []byte (id .String ()), message )
37
37
})
38
38
require .NoError (t , err )
39
39
defer cancel ()
40
- server , err := replica .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replica .Options {
40
+ server , err := replicasync .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replicasync .Options {
41
41
ID : id ,
42
42
})
43
43
require .NoError (t , err )
@@ -54,12 +54,12 @@ func TestReplica(t *testing.T) {
54
54
ID : id ,
55
55
})
56
56
require .NoError (t , err )
57
- cancel , err := pubsub .Subscribe (replica .PubsubEvent , func (ctx context.Context , message []byte ) {
57
+ cancel , err := pubsub .Subscribe (replicasync .PubsubEvent , func (ctx context.Context , message []byte ) {
58
58
assert .Equal (t , []byte (id .String ()), message )
59
59
})
60
60
require .NoError (t , err )
61
61
defer cancel ()
62
- server , err := replica .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replica .Options {
62
+ server , err := replicasync .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replicasync .Options {
63
63
ID : id ,
64
64
})
65
65
require .NoError (t , err )
@@ -84,7 +84,7 @@ func TestReplica(t *testing.T) {
84
84
RelayAddress : srv .URL ,
85
85
})
86
86
require .NoError (t , err )
87
- server , err := replica .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replica .Options {
87
+ server , err := replicasync .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replicasync .Options {
88
88
ID : uuid .New (),
89
89
})
90
90
require .NoError (t , err )
@@ -97,7 +97,7 @@ func TestReplica(t *testing.T) {
97
97
t .Parallel ()
98
98
db , pubsub := dbtestutil .NewDB (t )
99
99
var count atomic.Int32
100
- cancel , err := pubsub .Subscribe (replica .PubsubEvent , func (ctx context.Context , message []byte ) {
100
+ cancel , err := pubsub .Subscribe (replicasync .PubsubEvent , func (ctx context.Context , message []byte ) {
101
101
count .Add (1 )
102
102
})
103
103
require .NoError (t , err )
@@ -112,7 +112,7 @@ func TestReplica(t *testing.T) {
112
112
RelayAddress : "http://169.254.169.254" ,
113
113
})
114
114
require .NoError (t , err )
115
- server , err := replica .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replica .Options {
115
+ server , err := replicasync .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replicasync .Options {
116
116
ID : uuid .New (),
117
117
PeerTimeout : 1 * time .Millisecond ,
118
118
})
@@ -130,7 +130,7 @@ func TestReplica(t *testing.T) {
130
130
t .Parallel ()
131
131
db , pubsub := dbtestutil .NewDB (t )
132
132
id := uuid .New ()
133
- server , err := replica .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replica .Options {
133
+ server , err := replicasync .New (context .Background (), slogtest .Make (t , nil ), db , pubsub , replicasync .Options {
134
134
ID : id ,
135
135
})
136
136
require .NoError (t , err )
@@ -145,9 +145,9 @@ func TestReplica(t *testing.T) {
145
145
})
146
146
require .NoError (t , err )
147
147
// Publish multiple times to ensure it can handle that case.
148
- err = pubsub .Publish (replica .PubsubEvent , []byte (peer .ID .String ()))
148
+ err = pubsub .Publish (replicasync .PubsubEvent , []byte (peer .ID .String ()))
149
149
require .NoError (t , err )
150
- err = pubsub .Publish (replica .PubsubEvent , []byte (peer .ID .String ()))
150
+ err = pubsub .Publish (replicasync .PubsubEvent , []byte (peer .ID .String ()))
151
151
require .NoError (t , err )
152
152
require .Eventually (t , func () bool {
153
153
return len (server .Regional ()) == 1
@@ -168,7 +168,7 @@ func TestReplica(t *testing.T) {
168
168
count := 20
169
169
wg .Add (count )
170
170
for i := 0 ; i < count ; i ++ {
171
- server , err := replica .New (context .Background (), logger , db , pubsub , replica .Options {
171
+ server , err := replicasync .New (context .Background (), logger , db , pubsub , replicasync .Options {
172
172
ID : uuid .New (),
173
173
RelayAddress : srv .URL ,
174
174
})
0 commit comments