@@ -29,7 +29,27 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
29
29
// Add some state
30
30
fsm .state .EnsureNode (1 , & structs.Node {Node : "foo" , Address : "127.0.0.1" })
31
31
fsm .state .EnsureNode (2 , & structs.Node {Node : "baz" , Address : "127.0.0.2" , TaggedAddresses : map [string ]string {"hello" : "1.2.3.4" }, Meta : map [string ]string {"testMeta" : "testing123" }})
32
- fsm .state .EnsureService (3 , "foo" , & structs.NodeService {ID : "web" , Service : "web" , Tags : nil , Address : "127.0.0.1" , Port : 80 })
32
+
33
+ // Add a service instance with Connect config.
34
+ connectConf := structs.ServiceConnect {
35
+ Native : true ,
36
+ Proxy : & structs.ServiceDefinitionConnectProxy {
37
+ Command : []string {"foo" , "bar" },
38
+ ExecMode : "a" ,
39
+ Config : map [string ]interface {}{
40
+ "a" : "qwer" ,
41
+ "b" : 4.3 ,
42
+ },
43
+ },
44
+ }
45
+ fsm .state .EnsureService (3 , "foo" , & structs.NodeService {
46
+ ID : "web" ,
47
+ Service : "web" ,
48
+ Tags : nil ,
49
+ Address : "127.0.0.1" ,
50
+ Port : 80 ,
51
+ Connect : connectConf ,
52
+ })
33
53
fsm .state .EnsureService (4 , "foo" , & structs.NodeService {ID : "db" , Service : "db" , Tags : []string {"primary" }, Address : "127.0.0.1" , Port : 5000 })
34
54
fsm .state .EnsureService (5 , "baz" , & structs.NodeService {ID : "web" , Service : "web" , Tags : nil , Address : "127.0.0.2" , Port : 80 })
35
55
fsm .state .EnsureService (6 , "baz" , & structs.NodeService {ID : "db" , Service : "db" , Tags : []string {"secondary" }, Address : "127.0.0.2" , Port : 5000 })
@@ -131,6 +151,18 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
131
151
assert .Nil (err )
132
152
assert .True (ok )
133
153
154
+ // CA Config
155
+ caConfig := & structs.CAConfiguration {
156
+ ClusterID : "foo" ,
157
+ Provider : "consul" ,
158
+ Config : map [string ]interface {}{
159
+ "foo" : "asdf" ,
160
+ "bar" : 6.5 ,
161
+ },
162
+ }
163
+ err = fsm .state .CASetConfig (17 , caConfig )
164
+ assert .Nil (err )
165
+
134
166
// Snapshot
135
167
snap , err := fsm .Snapshot ()
136
168
if err != nil {
@@ -191,6 +223,10 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
191
223
if fooSrv .Services ["db" ].Port != 5000 {
192
224
t .Fatalf ("Bad: %v" , fooSrv )
193
225
}
226
+ connectSrv := fooSrv .Services ["web" ]
227
+ if ! reflect .DeepEqual (connectSrv .Connect , connectConf ) {
228
+ t .Fatalf ("got: %v, want: %v" , connectSrv .Connect , connectConf )
229
+ }
194
230
195
231
_ , checks , err := fsm2 .state .NodeChecks (nil , "foo" )
196
232
if err != nil {
@@ -312,6 +348,11 @@ func TestFSM_SnapshotRestore_OSS(t *testing.T) {
312
348
assert .Equal ("foo" , state .PrivateKey )
313
349
assert .Equal ("bar" , state .RootCert )
314
350
351
+ // Verify CA configuration is restored.
352
+ _ , caConf , err := fsm2 .state .CAConfig ()
353
+ assert .Nil (err )
354
+ assert .Equal (caConfig , caConf )
355
+
315
356
// Snapshot
316
357
snap , err = fsm2 .Snapshot ()
317
358
if err != nil {
0 commit comments