@@ -11,10 +11,8 @@ import (
1111
1212 networkTypes "github.com/docker/docker/api/types/network"
1313 "github.com/docker/docker/client"
14- "github.com/docker/go-connections/nat"
1514 "github.com/pkg/errors"
1615 "github.com/smartcontractkit/chainlink-testing-framework/framework"
17- "github.com/testcontainers/testcontainers-go"
1816 "github.com/testcontainers/testcontainers-go/modules/compose"
1917 "github.com/testcontainers/testcontainers-go/wait"
2018)
@@ -166,11 +164,6 @@ func New(in *Input) (*Output, error) {
166164 if chipIngressExternalHostErr != nil {
167165 return nil , errors .Wrap (chipIngressExternalHostErr , "failed to get host for Chip Ingress" )
168166 }
169- // for some magical reason mapped port sometimes cannot be found, even though we wait for it to be ready, when starting the services
170- chipIngressExternalPort , chipIngressExternalPortErr := findMappdePort (ctx , 31 * time .Second , chipIngressContainer , DEFAULT_CHIP_INGRESS_GRPC_PORT )
171- if chipIngressExternalPortErr != nil {
172- return nil , errors .Wrap (chipIngressExternalPortErr , "failed to get mapped port for Chip Ingress" )
173- }
174167
175168 redpandaContainer , redpandaErr := stack .ServiceContainer (ctx , DEFAULT_RED_PANDA_SERVICE_NAME )
176169 if redpandaErr != nil {
@@ -181,14 +174,6 @@ func New(in *Input) (*Output, error) {
181174 if redpandaExternalHostErr != nil {
182175 return nil , errors .Wrap (redpandaExternalHostErr , "failed to get host for Red Panda" )
183176 }
184- redpandaExternalKafkaPort , redpandaExternalKafkaPortErr := findMappdePort (ctx , 31 * time .Second , redpandaContainer , DEFAULT_RED_PANDA_KAFKA_PORT )
185- if redpandaExternalKafkaPortErr != nil {
186- return nil , errors .Wrap (redpandaExternalKafkaPortErr , "failed to get mapped port for Red Panda" )
187- }
188- redpandaExternalSchemaRegistryPort , redpandaExternalSchemaRegistryPortErr := findMappdePort (ctx , 31 * time .Second , redpandaContainer , DEFAULT_RED_PANDA_SCHEMA_REGISTRY_PORT )
189- if redpandaExternalSchemaRegistryPortErr != nil {
190- return nil , errors .Wrap (redpandaExternalSchemaRegistryPortErr , "failed to get mapped port for Red Panda" )
191- }
192177
193178 redpandaConsoleContainer , redpandaConsoleErr := stack .ServiceContainer (ctx , DEFAULT_RED_PANDA_CONSOLE_SERVICE_NAME )
194179 if redpandaConsoleErr != nil {
@@ -198,22 +183,18 @@ func New(in *Input) (*Output, error) {
198183 if redpandaExternalConsoleHostErr != nil {
199184 return nil , errors .Wrap (redpandaExternalConsoleHostErr , "failed to get host for Red Panda Console" )
200185 }
201- redpandaExternalConsolePort , redpandaExternalConsolePortErr := findMappdePort (ctx , 31 * time .Second , redpandaConsoleContainer , DEFAULT_RED_PANDA_CONSOLE_PORT )
202- if redpandaExternalConsolePortErr != nil {
203- return nil , errors .Wrap (redpandaExternalConsolePortErr , "failed to get mapped port for Red Panda Console" )
204- }
205186
206187 output := & Output {
207188 ChipIngress : & ChipIngressOutput {
208189 GRPCInternalURL : fmt .Sprintf ("http://%s:%s" , DEFAULT_CHIP_INGRESS_SERVICE_NAME , DEFAULT_CHIP_INGRESS_GRPC_PORT ),
209- GRPCExternalURL : fmt .Sprintf ("http://%s:%s" , chipIngressExternalHost , chipIngressExternalPort . Port () ),
190+ GRPCExternalURL : fmt .Sprintf ("http://%s:%s" , chipIngressExternalHost , DEFAULT_CHIP_INGRESS_GRPC_PORT ),
210191 },
211192 RedPanda : & RedPandaOutput {
212193 SchemaRegistryInternalURL : fmt .Sprintf ("http://%s:%s" , DEFAULT_RED_PANDA_SERVICE_NAME , DEFAULT_RED_PANDA_SCHEMA_REGISTRY_PORT ),
213- SchemaRegistryExternalURL : fmt .Sprintf ("http://%s:%s" , redpandaExternalHost , redpandaExternalSchemaRegistryPort . Port () ),
194+ SchemaRegistryExternalURL : fmt .Sprintf ("http://%s:%s" , redpandaExternalHost , DEFAULT_RED_PANDA_SCHEMA_REGISTRY_PORT ),
214195 KafkaInternalURL : fmt .Sprintf ("%s:%s" , DEFAULT_RED_PANDA_SERVICE_NAME , DEFAULT_RED_PANDA_KAFKA_PORT ),
215- KafkaExternalURL : fmt .Sprintf ("%s:%s" , redpandaExternalHost , redpandaExternalKafkaPort . Port () ),
216- ConsoleExternalURL : fmt .Sprintf ("http://%s:%s" , redpandaExternalConsoleHost , redpandaExternalConsolePort . Port () ),
196+ KafkaExternalURL : fmt .Sprintf ("%s:%s" , redpandaExternalHost , DEFAULT_RED_PANDA_KAFKA_PORT ),
197+ ConsoleExternalURL : fmt .Sprintf ("http://%s:%s" , redpandaExternalConsoleHost , DEFAULT_RED_PANDA_CONSOLE_PORT ),
217198 },
218199 }
219200
@@ -252,33 +233,6 @@ func composeFilePath(rawFilePath string) (string, error) {
252233 return tempFile .Name (), nil
253234}
254235
255- func findMappdePort (ctx context.Context , timeout time.Duration , container * testcontainers.DockerContainer , port nat.Port ) (nat.Port , error ) {
256- forCtx , cancel := context .WithTimeout (ctx , timeout )
257- defer cancel ()
258-
259- tickerInterval := 5 * time .Second
260- ticker := time .NewTicker (5 * time .Second )
261- defer ticker .Stop ()
262-
263- for {
264- select {
265- case <- forCtx .Done ():
266- return "" , fmt .Errorf ("timeout while waiting for mapped port for %s" , port )
267- case <- ticker .C :
268- portCtx , portCancel := context .WithTimeout (ctx , tickerInterval )
269- defer portCancel ()
270- mappedPort , mappedPortErr := container .MappedPort (portCtx , port )
271- if mappedPortErr != nil {
272- return "" , errors .Wrapf (mappedPortErr , "failed to get mapped port for %s" , port )
273- }
274- if mappedPort .Port () == "" {
275- return "" , fmt .Errorf ("mapped port for %s is empty" , port )
276- }
277- return mappedPort , nil
278- }
279- }
280- }
281-
282236func connectNetwork (connCtx context.Context , timeout time.Duration , dockerClient * client.Client , containerID , networkName , stackIdentifier string ) error {
283237 ticker := time .NewTicker (500 * time .Millisecond )
284238 defer ticker .Stop ()
0 commit comments