@@ -13,6 +13,8 @@ import (
1313 "github.com/smartcontractkit/chainlink-testing-framework/framework"
1414)
1515
16+ const DefaultUbuntuCACertificatePath = "/etc/ssl/certs/ca-certificates.crt"
17+
1618type ExposeWs = bool
1719
1820const (
@@ -28,20 +30,36 @@ func baseRequest(in *Input, useWS ExposeWs) testcontainers.ContainerRequest {
2830 exposedPorts = append (exposedPorts , fmt .Sprintf ("%s/tcp" , in .WSPort ))
2931 }
3032
31- return testcontainers.ContainerRequest {
32- Name : containerName ,
33- Labels : framework .DefaultTCLabels (),
34- Networks : []string {framework .DefaultNetworkName },
35- NetworkAliases : map [string ][]string {
36- framework .DefaultNetworkName : {containerName },
37- },
38- ExposedPorts : exposedPorts ,
33+ req := testcontainers.ContainerRequest {
34+ Name : containerName ,
35+ Labels : framework .DefaultTCLabels (),
3936 HostConfigModifier : func (h * container.HostConfig ) {
40- h .PortBindings = framework .MapTheSamePort (exposedPorts ... )
4137 framework .ResourceLimitsFunc (h , in .ContainerResources )
38+ if in .HostNetworkMode {
39+ h .NetworkMode = "host"
40+ } else {
41+ h .PortBindings = framework .MapTheSamePort (exposedPorts ... )
42+ }
4243 },
4344 WaitingFor : wait .ForListeningPort (nat .Port (in .Port )).WithStartupTimeout (15 * time .Second ).WithPollInterval (200 * time .Millisecond ),
4445 }
46+ if ! in .HostNetworkMode {
47+ req .ExposedPorts = exposedPorts
48+ req .Networks = []string {framework .DefaultNetworkName }
49+ req .NetworkAliases = map [string ][]string {
50+ framework .DefaultNetworkName : {containerName },
51+ }
52+ }
53+ if in .CertificatesPath != "" {
54+ req .Files = []testcontainers.ContainerFile {
55+ {
56+ HostFilePath : in .CertificatesPath ,
57+ ContainerFilePath : DefaultUbuntuCACertificatePath ,
58+ FileMode : 0644 ,
59+ },
60+ }
61+ }
62+ return req
4563}
4664
4765func createGenericEvmContainer (in * Input , req testcontainers.ContainerRequest , useWS bool ) (* Output , error ) {
@@ -59,10 +77,18 @@ func createGenericEvmContainer(in *Input, req testcontainers.ContainerRequest, u
5977 return nil , err
6078 }
6179
62- bindPort := req .ExposedPorts [0 ]
63- mp , err := c .MappedPort (ctx , nat .Port (bindPort ))
64- if err != nil {
65- return nil , err
80+ // specific case to bridge with GAPv2 in CI
81+ // we run blockchains on "host" network for connectivity
82+ var exposedPort string
83+ if in .HostNetworkMode {
84+ exposedPort = in .Port
85+ } else {
86+ bindPort := req .ExposedPorts [0 ]
87+ ep , err := c .MappedPort (ctx , nat .Port (bindPort ))
88+ if err != nil {
89+ return nil , err
90+ }
91+ exposedPort = ep .Port ()
6692 }
6793
6894 containerName := req .Name
@@ -76,8 +102,8 @@ func createGenericEvmContainer(in *Input, req testcontainers.ContainerRequest, u
76102 Container : c ,
77103 Nodes : []* Node {
78104 {
79- ExternalWSUrl : fmt .Sprintf ("ws://%s:%s" , host , mp . Port () ),
80- ExternalHTTPUrl : fmt .Sprintf ("http://%s:%s" , host , mp . Port () ),
105+ ExternalWSUrl : fmt .Sprintf ("ws://%s:%s" , host , exposedPort ),
106+ ExternalHTTPUrl : fmt .Sprintf ("http://%s:%s" , host , exposedPort ),
81107 InternalWSUrl : fmt .Sprintf ("ws://%s:%s" , containerName , in .Port ),
82108 InternalHTTPUrl : fmt .Sprintf ("http://%s:%s" , containerName , in .Port ),
83109 },
0 commit comments