-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathutils.go
More file actions
69 lines (56 loc) · 1.57 KB
/
Copy pathutils.go
File metadata and controls
69 lines (56 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Copyright IBM Corp All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package integration
import (
"time"
"github.com/onsi/gomega"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fsc/node"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/storage/driver/sql/postgres"
)
var NoReplication = &ReplicationOptions{}
type ReplicationOptions struct {
ReplicationFactors map[string]int
SQLConfigs map[string]*postgres.ContainerConfig
}
func (o *ReplicationOptions) For(name string) []node.Option {
opts := make([]node.Option, 0, 3)
if f := o.ReplicationFactors[name]; f > 0 {
opts = append(opts, fsc.WithReplicationFactor(f))
}
if sqlConfig, ok := o.SQLConfigs[name]; ok {
opts = append(opts,
fabric.WithDefaultPostgresPersistence(sqlConfig),
)
} else {
opts = append(opts,
fabric.WithDefaultSqlitePersistence(),
)
}
return opts
}
func NewTestSuite(generator func() (*Infrastructure, error)) *TestSuite {
return &TestSuite{
generator: generator,
}
}
type TestSuite struct {
generator func() (*Infrastructure, error)
II *Infrastructure
}
func (s *TestSuite) TearDown() {
s.II.Stop()
}
func (s *TestSuite) Setup() {
// Create the integration ii
ii, err := s.generator()
gomega.Expect(err).NotTo(gomega.HaveOccurred())
s.II = ii
// Start the integration ii
ii.Start()
// Sleep for a while to allow the networks to be ready
time.Sleep(3 * time.Second)
}