Skip to content

Commit 270607e

Browse files
testing(nwo/fabric-x): fix multi-orderer endpoint injection in mock container
The mock orderer test container only launches a single orderer process that listens on a single port for the entire mock cluster. This commit reverts the container configuration to bind only one port, and updates the configtx template generator to inject that single port for all orderer endpoints in the genesis block. This ensures that the fabric-smart-client broadcast service can successfully route transactions to the simulated multi-orderer cluster without hitting closed ports. Signed-off-by: Shashank <yshashank959@gmail.com>
1 parent fd17d7d commit 270607e

2 files changed

Lines changed: 17 additions & 22 deletions

File tree

integration/nwo/fabric/topology/configtx_template.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,13 @@ Organizations:{{ range .PeerOrgs }}
112112
Rule: OR('{{.MSPID}}.admin')
113113
{{- end }}
114114
OrdererEndpoints:{{ range $w.OrderersInOrg .Name }}
115+
{{- if eq $w.Consensus.Type "arma" }}
116+
{{- $firstOrderer := index $.Orderers 0 }}
117+
- {{ $w.OrdererHost . }}:{{ $w.OrdererPort $firstOrderer "Listen" }}
118+
{{- else }}
115119
- {{ $w.OrdererAddress . "Listen" }}
116120
{{- end }}
121+
{{- end }}
117122
{{ end }}
118123
119124
Channel: &ChannelDefaults
@@ -201,13 +206,15 @@ Profiles:{{ range .Profiles }}
201206
{{- end }}{{- end }}
202207
{{- end }}
203208
{{- if eq $w.Consensus.Type "arma" }}
209+
{{- $firstOrdererName := index .Orderers 0 }}
210+
{{- $firstOrderer := $w.Orderer $firstOrdererName }}
204211
ConsenterMapping:{{ range $index, $orderer := .Orderers }}{{ with $w.Orderer . }}
205212
- ID: {{ .Id }}
206213
Host: 127.0.0.1
207-
Port: {{ $w.OrdererPort . "Cluster" }}
214+
Port: {{ $w.OrdererPort $firstOrderer "Listen" }}
208215
MSPID: {{ ($w.Organization .Organization).MSPID}}
209-
ClientTLSCert: {{ $w.OrdererLocalCryptoDir . "tls" }}/server.crt
210-
ServerTLSCert: {{ $w.OrdererLocalCryptoDir . "tls" }}/server.crt
216+
ClientTLSCert: {{ $w.OrdererLocalCryptoDir $firstOrderer "tls" }}/server.crt
217+
ServerTLSCert: {{ $w.OrdererLocalCryptoDir $firstOrderer "tls" }}/server.crt
211218
Identity: {{ $w.OrdererSignCert .}}
212219
{{- end }}{{- end }}
213220
{{- end }}

integration/nwo/fabricx/extensions/scv2/container.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"path/filepath"
2020
"runtime"
2121
"strconv"
22-
"strings"
2322
"time"
2423

2524
"github.com/moby/moby/api/types/container"
@@ -50,14 +49,7 @@ func (e *Extension) launchContainer() {
5049
// get ports
5150
sidecarPort := int(e.network.PeerPort(sidecarPeer, fabric_network.ListenPort))
5251
queryServicePort := int(e.network.PeerPort(sidecarPeer, fabricx_network.QueryServicePortName))
53-
54-
var orderingServicePorts []int
55-
var orderingServiceEndpoints []string
56-
for _, o := range e.network.Orderers {
57-
port := int(e.network.OrdererPort(o, fabric_network.ListenPort))
58-
orderingServicePorts = append(orderingServicePorts, port)
59-
orderingServiceEndpoints = append(orderingServiceEndpoints, net.JoinHostPort("", strconv.Itoa(port)))
60-
}
52+
orderingServicePort := int(e.network.OrdererPort(e.network.Orderers[0], fabric_network.ListenPort))
6153

6254
// genesis block
6355
configBlockPath := e.network.OutputBlockPath(e.channel.Name)
@@ -85,7 +77,7 @@ func (e *Extension) launchContainer() {
8577
SidecarMSPID: fmt.Sprintf("%sMSP", e.cfg.SidecarOrg),
8678
SidecarServerEndpoint: net.JoinHostPort("", strconv.Itoa(sidecarPort)),
8779
QueryServerEndpoint: net.JoinHostPort("", strconv.Itoa(queryServicePort)),
88-
OrdererServerEndpoint: strings.Join(orderingServiceEndpoints, ","),
80+
OrdererServerEndpoint: net.JoinHostPort("", strconv.Itoa(orderingServicePort)),
8981
TLSEnabled: e.network.TLSEnabled,
9082
CertsBundle: path.Join("/root/artifacts/crypto", "ca-certs.pem"),
9183
SidecarTLSDir: containerSidecarTLSDir(e.network, sidecarPeer),
@@ -94,13 +86,9 @@ func (e *Extension) launchContainer() {
9486
EnvVarOverrides: e.cfg.EnvVars,
9587
}
9688

97-
logger.Infof("Run fabric-x committer test container on %v ports: sidecar=%v query=%v orderers=%v",
98-
localIP, sidecarPort, queryServicePort, orderingServicePorts)
89+
logger.Infof("Run fabric-x committer test container on %v ports: sidecar=%v query=%v orderer=%v",
90+
localIP, sidecarPort, queryServicePort, orderingServicePort)
9991

100-
var exposedPorts []int
101-
exposedPorts = append(exposedPorts, sidecarPort, queryServicePort)
102-
exposedPorts = append(exposedPorts, orderingServicePorts...)
103-
10492
cli := utils.MustGet(dcli.New(dcli.FromEnv))
10593
ctx := context.TODO()
10694
resp := utils.MustGet(cli.ContainerCreate(
@@ -112,7 +100,7 @@ func (e *Extension) launchContainer() {
112100
Tty: true,
113101
AttachStdout: true,
114102
AttachStderr: true,
115-
ExposedPorts: docker.PortSet(exposedPorts...),
103+
ExposedPorts: docker.PortSet(sidecarPort, queryServicePort, orderingServicePort),
116104
Env: containerEnvVars(cfg),
117105
Cmd: containerCmd(cfg),
118106
},
@@ -138,7 +126,7 @@ func (e *Extension) launchContainer() {
138126
ReadOnly: true,
139127
},
140128
},
141-
PortBindings: docker.PortBindings(exposedPorts...),
129+
PortBindings: docker.PortBindings(sidecarPort, queryServicePort, orderingServicePort),
142130
},
143131
NetworkingConfig: &network.NetworkingConfig{
144132
EndpointsConfig: map[string]*network.EndpointSettings{
@@ -207,7 +195,7 @@ func (e *Extension) launchContainer() {
207195

208196
// let's wait until the sidecar is ready
209197
g, ctx := errgroup.WithContext(ctx)
210-
for _, p := range exposedPorts {
198+
for _, p := range []int{sidecarPort, orderingServicePort, queryServicePort} {
211199
g.Go(func() error {
212200
addr := net.JoinHostPort("127.0.0.1", strconv.Itoa(p))
213201
return fabric.WaitUntilReadyWithTLS(ctx, addr, tlsConfig)

0 commit comments

Comments
 (0)