Skip to content

Commit 2bcee40

Browse files
committed
control resources for default components
1 parent aab81e4 commit 2bcee40

File tree

17 files changed

+96
-28
lines changed

17 files changed

+96
-28
lines changed

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Debugging Tests](framework/components/debug.md)
2323
- [Components Cleanup](framework/components/cleanup.md)
2424
- [Components Caching](framework/components/caching.md)
25+
- [Components Resources](framework/components/resources.md)
2526
- [Mocking Services](framework/components/mocking.md)
2627
- [Copying Files](framework/copying_files.md)
2728
- [External Environment](framework/components/external.md)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Components Resources

framework/.changeset/v0.4.7.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Set cgroups resource for containers

framework/components/blockchain/anvil.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func newAnvil(in *Input) (*Output, error) {
4848
ExposedPorts: []string{bindPort},
4949
HostConfigModifier: func(h *container.HostConfig) {
5050
h.PortBindings = framework.MapTheSamePort(bindPort)
51+
framework.ResourceLimitsFunc(h, in.ContainerResources)
5152
},
5253
Networks: []string{framework.DefaultNetworkName},
5354
NetworkAliases: map[string][]string{

framework/components/blockchain/aptos.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func newAptos(in *Input) (*Output, error) {
4949
},
5050
HostConfigModifier: func(h *container.HostConfig) {
5151
h.PortBindings = framework.MapTheSamePort(bindPort)
52+
framework.ResourceLimitsFunc(h, in.ContainerResources)
5253
},
5354
ImagePlatform: "linux/amd64",
5455
Cmd: []string{

framework/components/blockchain/besu.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func newBesu(in *Input) (*Output, error) {
6868
Labels: framework.DefaultTCLabels(),
6969
HostConfigModifier: func(h *container.HostConfig) {
7070
h.PortBindings = framework.MapTheSamePort(bindPortWs, bindPort)
71+
framework.ResourceLimitsFunc(h, in.ContainerResources)
7172
},
7273
WaitingFor: wait.ForListeningPort(nat.Port(in.Port)).WithStartupTimeout(15 * time.Second).WithPollInterval(200 * time.Millisecond),
7374
Cmd: entryPoint,

framework/components/blockchain/blockchain.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package blockchain
22

33
import (
44
"fmt"
5+
"github.com/smartcontractkit/chainlink-testing-framework/framework"
56
"github.com/testcontainers/testcontainers-go"
67
)
78

@@ -25,7 +26,8 @@ type Input struct {
2526
// programs to deploy on solana-test-validator start
2627
// a map of program name to program id
2728
// there needs to be a matching .so file in contracts_dir
28-
SolanaPrograms map[string]string `toml:"solana_programs"`
29+
SolanaPrograms map[string]string `toml:"solana_programs"`
30+
ContainerResources *framework.ContainerResources `toml:"resources"`
2931
}
3032

3133
// Output is a blockchain network output, ChainID and one or more nodes that forms the network

framework/components/blockchain/geth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ func newGeth(in *Input) (*Output, error) {
167167
ExposedPorts: []string{bindPort},
168168
HostConfigModifier: func(h *container.HostConfig) {
169169
h.PortBindings = framework.MapTheSamePort(bindPort)
170+
framework.ResourceLimitsFunc(h, in.ContainerResources)
170171
h.Mounts = append(h.Mounts, mount.Mount{
171172
Type: mount.TypeBind,
172173
Source: keystoreDir,

framework/components/blockchain/solana.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func newSolana(in *Input) (*Output, error) {
105105
WithPollInterval(100 * time.Millisecond),
106106
HostConfigModifier: func(h *container.HostConfig) {
107107
h.PortBindings = framework.MapTheSamePort(bindPort, wsBindPort)
108+
framework.ResourceLimitsFunc(h, in.ContainerResources)
108109
h.Mounts = append(h.Mounts, mount.Mount{
109110
Type: mount.TypeBind,
110111
Source: contractsDir,

framework/components/blockchain/sui.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func newSui(in *Input) (*Output, error) {
104104
},
105105
HostConfigModifier: func(h *container.HostConfig) {
106106
h.PortBindings = framework.MapTheSamePort(bindPort, DefaultFaucetPort)
107+
framework.ResourceLimitsFunc(h, in.ContainerResources)
107108
},
108109
ImagePlatform: "linux/amd64",
109110
Env: map[string]string{

0 commit comments

Comments
 (0)