Skip to content

Commit 8f3a11d

Browse files
committed
Cleanup
1 parent e1c8371 commit 8f3a11d

23 files changed

+13
-117
lines changed

lib/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ Basic and universal building blocks for TOML-based config are provided by `confi
413413

414414
An ecr mirror can be used to push images used often in order to bypass rate limit issues from dockerhub. The list of image mirrors can be found in the [matrix here](./.github/workflows/update-internal-mirrors.yaml). This currently works with images with version numbers in dockerhub. Support for gcr is coming in the future. The images must also have a version number so putting `latest` will not work. We have a separate list for one offs we want that can be added to [here](./scripts/mirror.json) that does work with gcr and latest images. Note however for `latest` it will only pull it once and will not update it in our mirror if the latest on the public repository has changed, in this case it is preferable to update it manually when you know that you need the new latest and the update will not break your tests.
415415

416-
For images in the mirrors you can use the INTERNAL_DOCKER_REPO environment variable when running tests and it will use that mirror in place of the public repository.
416+
For images in the mirrors you can use the TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX environment variable when running tests and it will use that mirror in place of the public repository.
417417

418418
We have two ways to add new images to the ecr. The first two requirements are that you create the ecr repository with the same name as the one in dockerhub out in aws and then add that ecr to the infra permissions (ask TT if you don't know how to do this).
419419

lib/docker/docker.go

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,25 @@
11
package docker
22

33
import (
4-
"fmt"
4+
"context"
55
"strings"
66

7-
"github.com/google/uuid"
87
"github.com/rs/zerolog"
98
tc "github.com/testcontainers/testcontainers-go"
9+
tc_network "github.com/testcontainers/testcontainers-go/network"
1010

11-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
1211
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
1312
)
1413

1514
const RetryAttempts = 3
16-
const defaultRyukImage = "testcontainers/ryuk:0.5.1"
1715

1816
func CreateNetwork(l zerolog.Logger) (*tc.DockerNetwork, error) {
19-
uuidObj, _ := uuid.NewRandom()
20-
var networkName = fmt.Sprintf("network-%s", uuidObj.String())
21-
ryukImage := mirror.AddMirrorToImageIfSet(defaultRyukImage)
22-
// currently there's no way to use custom Ryuk image with testcontainers-go v0.28.0 :/
23-
// but we can go around it, by setting TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX env var to
24-
// our custom registry and then using the default Ryuk image
25-
//nolint:staticcheck
26-
reaperCO := tc.WithImageName(ryukImage)
27-
f := false
28-
//nolint:staticcheck
29-
network, err := tc.GenericNetwork(testcontext.Get(nil), tc.GenericNetworkRequest{
30-
//nolint:staticcheck
31-
NetworkRequest: tc.NetworkRequest{
32-
Name: networkName,
33-
CheckDuplicate: true,
34-
EnableIPv6: &f, // disabling due to https://github.com/moby/moby/issues/42442
35-
ReaperOptions: []tc.ContainerOption{
36-
reaperCO,
37-
},
38-
},
39-
})
17+
network, err := tc_network.New(context.Background())
4018
if err != nil {
4119
return nil, err
4220
}
43-
dockerNetwork, ok := network.(*tc.DockerNetwork)
44-
if !ok {
45-
return nil, fmt.Errorf("failed to cast network to *dockertest.Network")
46-
}
47-
l.Trace().Any("network", dockerNetwork).Msgf("created network")
48-
return dockerNetwork, nil
21+
l.Trace().Str("Name", network.Name).Msg("Created network")
22+
return network, nil
4923
}
5024

5125
type StartContainerRetrier func(l zerolog.Logger, startErr error, req tc.GenericContainerRequest) (tc.Container, error)

lib/docker/test_env/besu_eth1.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/smartcontractkit/chainlink-testing-framework/lib/config"
1818
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/ethereum"
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
20-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2120
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/templates"
2221
)
2322

@@ -46,9 +45,6 @@ func NewBesuEth1(networks []string, chainConfig *config.EthereumChainConfig, opt
4645
g.EnvComponent.ContainerName = fmt.Sprintf("%s-%s-%s", "besu-eth1", strings.Replace(g.ContainerVersion, ".", "_", -1), uuid.NewString()[0:8])
4746
}
4847

49-
// if the internal docker repo is set then add it to the version
50-
g.EnvComponent.ContainerImage = mirror.AddMirrorToImageIfSet(g.EnvComponent.ContainerImage)
51-
5248
return g, nil
5349
}
5450

lib/docker/test_env/besu_eth2.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/smartcontractkit/chainlink-testing-framework/lib/config"
1818
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/ethereum"
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
20-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2120
docker_utils "github.com/smartcontractkit/chainlink-testing-framework/lib/utils/docker"
2221
)
2322

@@ -47,8 +46,6 @@ func NewBesuEth2(networks []string, chainConfig *config.EthereumChainConfig, gen
4746
// set the container name again after applying functional options as version might have changed
4847
g.EnvComponent.ContainerName = fmt.Sprintf("%s-%s-%s", "besu-eth2", strings.Replace(g.ContainerVersion, ".", "_", -1), uuid.NewString()[0:8])
4948
}
50-
// if the internal docker repo is set then add it to the version
51-
g.EnvComponent.ContainerImage = mirror.AddMirrorToImageIfSet(g.EnvComponent.ContainerImage)
5249

5350
return g, nil
5451
}

lib/docker/test_env/erigon_eth1.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
config_types "github.com/smartcontractkit/chainlink-testing-framework/lib/config/types"
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/ethereum"
2020
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
21-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2221
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/templates"
2322
)
2423

@@ -46,8 +45,6 @@ func NewErigonEth1(networks []string, chainConfig *config.EthereumChainConfig, o
4645
// set the container name again after applying functional options as version might have changed
4746
g.EnvComponent.ContainerName = fmt.Sprintf("%s-%s-%s", "erigon-eth1", strings.Replace(g.ContainerVersion, ".", "_", -1), uuid.NewString()[0:8])
4847
}
49-
// if the internal docker repo is set then add it to the version
50-
g.EnvComponent.ContainerImage = mirror.AddMirrorToImageIfSet(g.EnvComponent.ContainerImage)
5148
return g, nil
5249
}
5350

lib/docker/test_env/erigon_eth2.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
config_types "github.com/smartcontractkit/chainlink-testing-framework/lib/config/types"
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/ethereum"
2020
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
21-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2221
)
2322

2423
// NewErigonEth2 starts a new Erigon Eth2 node running in Docker
@@ -47,8 +46,6 @@ func NewErigonEth2(networks []string, chainConfig *config.EthereumChainConfig, g
4746
// set the container name again after applying functional options as version might have changed
4847
g.EnvComponent.ContainerName = fmt.Sprintf("%s-%s-%s", "erigon-eth2", strings.Replace(g.ContainerVersion, ".", "_", -1), uuid.NewString()[0:8])
4948
}
50-
// if the internal docker repo is set then add it to the version
51-
g.EnvComponent.ContainerImage = mirror.AddMirrorToImageIfSet(g.EnvComponent.ContainerImage)
5249
return g, nil
5350
}
5451

lib/docker/test_env/genesis_generator.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker"
2020
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/ethereum"
2121
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
22-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2322
)
2423

2524
var generatorForkToImageMap = map[ethereum.Fork]string{
@@ -69,8 +68,6 @@ func NewEthGenesisGenerator(chainConfig config.EthereumChainConfig, generatedDat
6968
for _, opt := range opts {
7069
opt(&g.EnvComponent)
7170
}
72-
// if the internal docker repo is set then add it to the version
73-
g.EnvComponent.ContainerImage = mirror.AddMirrorToImageIfSet(g.EnvComponent.ContainerImage)
7471
return g, nil
7572
}
7673

lib/docker/test_env/geth_eth1.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"github.com/smartcontractkit/chainlink-testing-framework/lib/config"
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/ethereum"
2020
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
21-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2221
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/templates"
2322
)
2423

@@ -46,8 +45,6 @@ func NewGethEth1(networks []string, chainConfig *config.EthereumChainConfig, opt
4645
// set the container name again after applying functional options as version might have changed
4746
g.EnvComponent.ContainerName = fmt.Sprintf("%s-%s-%s", "geth-eth1", strings.Replace(g.ContainerVersion, ".", "_", -1), uuid.NewString()[0:8])
4847
}
49-
// if the internal docker repo is set then add it to the version
50-
g.EnvComponent.ContainerImage = mirror.AddMirrorToImageIfSet(g.EnvComponent.ContainerImage)
5148
return g
5249
}
5350

lib/docker/test_env/geth_eth2.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/config"
2020
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker/ethereum"
2121
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
22-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2322
)
2423

2524
// NewGethEth2 starts a new Geth Eth2 node running in Docker
@@ -48,8 +47,6 @@ func NewGethEth2(networks []string, chainConfig *config.EthereumChainConfig, gen
4847
// set the container name again after applying functional options as version might have changed
4948
g.EnvComponent.ContainerName = fmt.Sprintf("%s-%s-%s", "geth-eth2", strings.Replace(g.ContainerVersion, ".", "_", -1), uuid.NewString()[0:8])
5049
}
51-
// if the internal docker repo is set then add it to the version
52-
g.EnvComponent.ContainerImage = mirror.AddMirrorToImageIfSet(g.EnvComponent.ContainerImage)
5350
return g, nil
5451
}
5552

lib/docker/test_env/kafka.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717

1818
"github.com/smartcontractkit/chainlink-testing-framework/lib/docker"
1919
"github.com/smartcontractkit/chainlink-testing-framework/lib/logging"
20-
"github.com/smartcontractkit/chainlink-testing-framework/lib/mirror"
2120
"github.com/smartcontractkit/chainlink-testing-framework/lib/utils/testcontext"
2221
)
2322

@@ -162,10 +161,9 @@ func (k *Kafka) CreateLocalTopics() error {
162161
}
163162

164163
func (k *Kafka) getContainerRequest() (tc.ContainerRequest, error) {
165-
kafkaImage := mirror.AddMirrorToImageIfSet(defaultKafkaImage)
166164
return tc.ContainerRequest{
167165
Name: k.ContainerName,
168-
Image: kafkaImage,
166+
Image: defaultKafkaImage,
169167
ExposedPorts: []string{"29092/tcp"},
170168
Env: k.EnvVars,
171169
Networks: k.Networks,

0 commit comments

Comments
 (0)