Skip to content

Commit b1b8d05

Browse files
committed
Attempt to fix issue with refactor on linux
When attempting to run the refactor on a linux machine, some errors are encountered. When Asking @philippecamacho about the errors encountered he provided the error: `"unable to determine the host for the espresso-dev-node sequencer api"` This error occurs when the remapping has failed. Comparing the refactor changes against the original implementation indicated a slight change in the logic. The change is meant to ensure that the port is populated correctly on the container port map. However it only checks the remapped values which are always populated with the given value. This makes this condition a tautological expression which will never remap when it should. This fix changes the inspected value, and also adds a fail-safe to always process the re-assignment when the `network` is set to `"host"`.
1 parent d5c371c commit b1b8d05

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

espresso/environment/optitmism_espresso_test_helpers.go

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -780,21 +780,24 @@ func determineDockerNetworkMode() string {
780780
// remapped port values. This is done for convenience in order to ensure that
781781
// we can still reference the hard coded ports, even if they've been remapped
782782
// from their original values.
783-
func ensureHardCodedPortsAreMappedFromTheirOriginalValues(containerInfo *DockerContainerInfo, portRemapping map[string]string) {
784-
if _, ok := portRemapping[ESPRESSO_SEQUENCER_API_PORT]; !ok {
785-
// If we don't have the original port mapping for the hard
786-
// coded port, we will need to back fill them in, just
787-
// to make life easier for consumers.
788-
789-
for portKey, portValue := range portRemapping {
790-
// We copy the port mapping information
791-
// so we know the original mapping again,
792-
// since we're hard-coding the ports to use.
793-
// This should allow us to run multiple
794-
// e2e test environments in parallel on
795-
// linux as well.
796-
containerInfo.PortMap[portKey] = containerInfo.PortMap[portValue]
797-
}
783+
func ensureHardCodedPortsAreMappedFromTheirOriginalValues(containerInfo *DockerContainerInfo, portRemapping map[string]string, network string) {
784+
if network != "host" {
785+
// nothing needs to be modified
786+
return
787+
}
788+
789+
// If we don't have the original port mapping for the hard
790+
// coded port, we will need to back fill them in, just
791+
// to make life easier for consumers.
792+
793+
for portKey, portValue := range portRemapping {
794+
// We copy the port mapping information
795+
// so we know the original mapping again,
796+
// since we're hard-coding the ports to use.
797+
// This should allow us to run multiple
798+
// e2e test environments in parallel on
799+
// linux as well.
800+
containerInfo.PortMap[portKey] = containerInfo.PortMap[portValue]
798801
}
799802
}
800803

@@ -840,8 +843,9 @@ func launchEspressoDevNodeStartOption(ct *DevNetLauncherContext) e2esys.StartOpt
840843
return
841844
}
842845

843-
ensureHardCodedPortsAreMappedFromTheirOriginalValues(&espressoDevNodeContainerInfo, portRemapping)
846+
ensureHardCodedPortsAreMappedFromTheirOriginalValues(&espressoDevNodeContainerInfo, portRemapping, network)
844847

848+
// Wait for Espresso to be ready
845849
if err := waitForEspressoToFinishSpinningUp(ct, espressoDevNodeContainerInfo); err != nil {
846850
ct.Error = err
847851
return
@@ -854,7 +858,8 @@ func launchEspressoDevNodeStartOption(ct *DevNetLauncherContext) e2esys.StartOpt
854858

855859
espressoDevNode := &EspressoDevNodeDockerContainerInfo{
856860
DockerContainerInfo: espressoDevNodeContainerInfo,
857-
espressoUrls: []string{"http://" + hostPort},
861+
// To create a valid multiple nodes client, we need to provide at least 2 URLs.
862+
espressoUrls: []string{"http://" + hostPort, "http://" + hostPort},
858863
}
859864
ct.EspressoDevNode = espressoDevNode
860865

0 commit comments

Comments
 (0)