Skip to content

Commit

Permalink
v0.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
skudasov committed Jan 13, 2025
1 parent cfdeeab commit 49fbb63
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 28 deletions.
3 changes: 3 additions & 0 deletions framework/.changeset/v0.4.2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Name logs subdir as test name
- Mutex for concurrent mock Record access
- Remove Promtail only through CLI
2 changes: 1 addition & 1 deletion framework/cmd/observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func observabilityDown() error {
framework.L.Info().Msg("Removing local observability stack")
err := runCommand("bash", "-c", fmt.Sprintf(`
cd %s && \
docker compose down -v
docker compose down -v && docker rm -f promtail
`, "compose"))
if err != nil {
return err
Expand Down
5 changes: 3 additions & 2 deletions framework/components/simple_node_set/reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"github.com/smartcontractkit/chainlink-testing-framework/framework"
"github.com/smartcontractkit/chainlink-testing-framework/framework/chaos"
"github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
"testing"
"time"
)

// UpgradeNodeSet updates nodes configuration TOML files
// this API is discouraged, however, you can use it if nodes require restart or configuration updates, temporarily!
func UpgradeNodeSet(in *Input, bc *blockchain.Output, wait time.Duration) (*Output, error) {
uniq := fmt.Sprintf("%s-%s", framework.DefaultCTFLogsDir, uuid.NewString()[0:4])
func UpgradeNodeSet(t *testing.T, in *Input, bc *blockchain.Output, wait time.Duration) (*Output, error) {
uniq := fmt.Sprintf("%s-%s-%s", framework.DefaultCTFLogsDir, t.Name(), uuid.NewString()[0:4])
if err := framework.WriteAllContainersLogs(uniq); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion framework/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func Load[X any](t *testing.T) (*X, error) {
t.Cleanup(func() {
err := Store[X](input)
require.NoError(t, err)
err = WriteAllContainersLogs(DefaultCTFLogsDir)
err = WriteAllContainersLogs(fmt.Sprintf("%s-%s", DefaultCTFLogsDir, t.Name()))
require.NoError(t, err)
err = checkAllNodeLogErrors()
require.NoError(t, err)
Expand Down
29 changes: 8 additions & 21 deletions framework/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/binary"
"fmt"
"github.com/docker/docker/api/types/container"
filters2 "github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"github.com/google/uuid"
Expand Down Expand Up @@ -175,23 +176,6 @@ func (dc *DockerClient) copyToContainer(containerID, sourceFile, targetPath stri
return nil
}

func in(s string, substrings []string) bool {
for _, substr := range substrings {
if strings.Contains(s, substr) {
return true
}
}
return false
}

func isLocalToolDockerContainer(containerName string) bool {
if in(containerName, []string{"/sig-provider", "/stats", "/stats-db", "/db", "/backend", "/promtail", "/compose", "/blockscout", "/frontend", "/user-ops-indexer", "/visualizer", "/redis-db", "/proxy"}) {
L.Debug().Str("Container", containerName).Msg("Ignoring local tool container output")
return true
}
return false
}

// WriteAllContainersLogs writes all Docker container logs to the default logs directory
func WriteAllContainersLogs(dir string) error {
L.Info().Msg("Writing Docker containers logs")
Expand All @@ -204,7 +188,13 @@ func WriteAllContainersLogs(dir string) error {
if err != nil {
return fmt.Errorf("failed to create Docker provider: %w", err)
}
containers, err := provider.Client().ContainerList(context.Background(), container.ListOptions{All: true})
containers, err := provider.Client().ContainerList(context.Background(), container.ListOptions{
All: true,
Filters: filters2.NewArgs(filters2.KeyValuePair{
Key: "label",
Value: "framework=ctf",
}),
})
if err != nil {
return fmt.Errorf("failed to list Docker containers: %w", err)
}
Expand All @@ -214,9 +204,6 @@ func WriteAllContainersLogs(dir string) error {
for _, containerInfo := range containers {
eg.Go(func() error {
containerName := containerInfo.Names[0]
if isLocalToolDockerContainer(containerName) {
return nil
}
L.Debug().Str("Container", containerName).Msg("Collecting logs")
logOptions := container.LogsOptions{ShowStdout: true, ShowStderr: true}
logs, err := provider.Client().ContainerLogs(context.Background(), containerInfo.ID, logOptions)
Expand Down
27 changes: 26 additions & 1 deletion framework/examples/myproject/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/blocto/solana-go-sdk v1.30.0
github.com/ethereum/go-ethereum v1.14.11
github.com/go-resty/resty/v2 v2.15.3
github.com/smartcontractkit/chainlink-testing-framework/framework v0.0.0-00010101000000-000000000000
github.com/smartcontractkit/chainlink-testing-framework/framework v0.4.1
github.com/smartcontractkit/chainlink-testing-framework/seth v1.50.10
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.2
github.com/stretchr/testify v1.10.0
Expand All @@ -35,6 +35,7 @@ require (
github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/avast/retry-go v3.0.0+incompatible // indirect
github.com/awalterschulze/gographviz v2.0.3+incompatible // indirect
github.com/aws/aws-sdk-go v1.45.25 // indirect
Expand All @@ -52,6 +53,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.4 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.0 // indirect
github.com/aws/smithy-go v1.22.1 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/benbjohnson/clock v1.3.5 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
Expand All @@ -60,9 +62,18 @@ require (
github.com/bytedance/sonic v1.12.3 // indirect
github.com/bytedance/sonic/loader v0.2.0 // indirect
github.com/c2h5oh/datasize v0.0.0-20220606134207-859f65c6625b // indirect
github.com/catppuccin/go v0.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/charmbracelet/bubbles v0.20.0 // indirect
github.com/charmbracelet/bubbletea v1.1.1 // indirect
github.com/charmbracelet/huh v0.6.0 // indirect
github.com/charmbracelet/huh/spinner v0.0.0-20241028115900-20a4d21717a8 // indirect
github.com/charmbracelet/lipgloss v0.13.0 // indirect
github.com/charmbracelet/x/ansi v0.2.3 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/term v0.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/coder/websocket v1.8.12 // indirect
Expand All @@ -73,6 +84,7 @@ require (
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand All @@ -87,6 +99,7 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/edsrzf/mmap-go v1.1.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240829091221-dffa7562dbe9 // indirect
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb // indirect
Expand Down Expand Up @@ -161,14 +174,18 @@ require (
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/miekg/dns v1.1.56 // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
Expand All @@ -183,6 +200,9 @@ require (
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.3-0.20240618155329-98d742f6907a // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
github.com/oklog/ulid v1.3.1 // indirect
Expand All @@ -191,6 +211,7 @@ require (
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e // indirect
github.com/opentracing-contrib/go-stdlib v1.0.0 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
Expand All @@ -205,8 +226,10 @@ require (
github.com/prometheus/exporter-toolkit v0.10.1-0.20230714054209-2f4150c63f97 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/prometheus/prometheus v0.47.2-0.20231010075449-4b9c19fe5510 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/rs/zerolog v1.33.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/sercand/kuberesolver/v5 v5.1.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand All @@ -227,7 +250,9 @@ require (
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/urfave/cli/v2 v2.27.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.etcd.io/etcd/api/v3 v3.5.14 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.14 // indirect
Expand Down
Loading

0 comments on commit 49fbb63

Please sign in to comment.