@@ -45,27 +45,36 @@ func TestSpawnEtcdRaft(t *testing.T) {
45
45
46
46
defer gexec .CleanupBuildArtifacts ()
47
47
48
- t .Run ("EtcdRaft launch failure" , func (t * testing.T ) {
49
- testEtcdRaftOSNFailure (gt , tempDir , orderer , fabricRootDir )
48
+ t .Run ("Invalid bootstrap block" , func (t * testing.T ) {
49
+ testEtcdRaftOSNFailureInvalidBootstrapBlock (gt , tempDir , orderer , fabricRootDir )
50
+ })
51
+
52
+ t .Run ("No TLS" , func (t * testing.T ) {
53
+ testEtcdRaftOSNNoTLS (gt , tempDir , orderer , fabricRootDir , configtxgen )
50
54
})
51
55
52
56
t .Run ("EtcdRaft launch success" , func (t * testing.T ) {
53
57
testEtcdRaftOSNSuccess (gt , tempDir , configtxgen , cwd , orderer , fabricRootDir )
54
58
})
55
59
}
56
60
57
- func testEtcdRaftOSNSuccess (gt * GomegaWithT , tempDir , configtxgen , cwd , orderer , fabricRootDir string ) {
61
+ func createBootstrapBlock (gt * GomegaWithT , tempDir , configtxgen , cwd string ) string {
58
62
// Create the genesis block for the system channel
59
63
genesisBlockPath := filepath .Join (tempDir , "genesis.block" )
60
64
cmd := exec .Command (configtxgen , "-channelID" , "system" , "-profile" , "SampleDevModeEtcdRaft" ,
61
65
"-outputBlock" , genesisBlockPath )
62
66
cmd .Env = append (cmd .Env , fmt .Sprintf ("FABRIC_CFG_PATH=%s" , filepath .Join (cwd , "testdata" )))
63
67
configtxgenProcess , err := gexec .Start (cmd , nil , nil )
64
68
gt .Expect (err ).NotTo (HaveOccurred ())
65
-
66
69
gt .Eventually (configtxgenProcess , time .Minute ).Should (gexec .Exit (0 ))
67
70
gt .Expect (configtxgenProcess .Err ).To (gbytes .Say ("Writing genesis block" ))
68
71
72
+ return genesisBlockPath
73
+ }
74
+
75
+ func testEtcdRaftOSNSuccess (gt * GomegaWithT , tempDir , configtxgen , cwd , orderer , fabricRootDir string ) {
76
+ genesisBlockPath := createBootstrapBlock (gt , tempDir , configtxgen , cwd )
77
+
69
78
// Launch the OSN
70
79
ordererProcess := launchOrderer (gt , orderer , tempDir , genesisBlockPath , fabricRootDir )
71
80
defer ordererProcess .Kill ()
@@ -90,7 +99,7 @@ func testEtcdRaftOSNSuccess(gt *GomegaWithT, tempDir, configtxgen, cwd, orderer,
90
99
gt .Eventually (ordererProcess .Err , time .Minute ).Should (gbytes .Say ("becomeLeader" ))
91
100
}
92
101
93
- func testEtcdRaftOSNFailure (gt * GomegaWithT , tempDir , orderer , fabricRootDir string ) {
102
+ func testEtcdRaftOSNFailureInvalidBootstrapBlock (gt * GomegaWithT , tempDir , orderer , fabricRootDir string ) {
94
103
// Grab an application channel genesis block
95
104
genesisBlockPath := filepath .Join (filepath .Join ("testdata" , "mychannel.block" ))
96
105
genesisBlockBytes , err := ioutil .ReadFile (genesisBlockPath )
@@ -109,6 +118,29 @@ func testEtcdRaftOSNFailure(gt *GomegaWithT, tempDir, orderer, fabricRootDir str
109
118
gt .Eventually (ordererProcess .Err , time .Minute ).Should (gbytes .Say (expectedErr ))
110
119
}
111
120
121
+ func testEtcdRaftOSNNoTLS (gt * GomegaWithT , tempDir , orderer , fabricRootDir string , configtxgen string ) {
122
+ cwd , err := filepath .Abs ("." )
123
+ gt .Expect (err ).NotTo (HaveOccurred ())
124
+
125
+ genesisBlockPath := createBootstrapBlock (gt , tempDir , configtxgen , cwd )
126
+
127
+ cmd := exec .Command (orderer )
128
+ cmd .Env = []string {
129
+ "ORDERER_GENERAL_LISTENPORT=5611" ,
130
+ "ORDERER_GENERAL_GENESISMETHOD=file" ,
131
+ "ORDERER_GENERAL_SYSTEMCHANNEL=system" ,
132
+ fmt .Sprintf ("ORDERER_FILELEDGER_LOCATION=%s" , filepath .Join (tempDir , "ledger" )),
133
+ fmt .Sprintf ("ORDERER_GENERAL_GENESISFILE=%s" , genesisBlockPath ),
134
+ fmt .Sprintf ("FABRIC_CFG_PATH=%s" , filepath .Join (fabricRootDir , "sampleconfig" )),
135
+ }
136
+ ordererProcess , err := gexec .Start (cmd , nil , nil )
137
+ gt .Expect (err ).NotTo (HaveOccurred ())
138
+ defer ordererProcess .Kill ()
139
+
140
+ expectedErr := "TLS is required for running ordering nodes of type etcdraft."
141
+ gt .Eventually (ordererProcess .Err , time .Minute ).Should (gbytes .Say (expectedErr ))
142
+ }
143
+
112
144
func launchOrderer (gt * GomegaWithT , orderer , tempDir , genesisBlockPath , fabricRootDir string ) * gexec.Session {
113
145
cwd , err := filepath .Abs ("." )
114
146
gt .Expect (err ).NotTo (HaveOccurred ())
0 commit comments