Skip to content

Commit

Permalink
Merge branch 'main' into tt-1930-perf-tool-add-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel committed Jan 8, 2025
2 parents 04dac45 + 1374a36 commit a7de13a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 17 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ jobs:
- name: Run pre-commit checks
run: |
nix develop -c sh -c "pre-commit run --hook-stage pre-commit --show-diff-on-failure --color=always"
clean-go-mods:
name: Clean go mods
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.23.3
uses: actions/setup-go@v5
with:
go-version: '1.23.3'
- name: Install gomods
run: go install github.com/jmank88/[email protected]
- name: Check out code
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
- name: Run gomods tidy
run: gomods tidy
- name: Ensure clean after tidy
run: |
git add --all
git diff --minimal --cached --exit-code
tools:
name: Get tool-versions
runs-on: ubuntu-latest
Expand Down
39 changes: 32 additions & 7 deletions lib/docker/docker.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package docker

import (
"context"
"fmt"
"strings"

"github.com/docker/docker/api/types/container"
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rs/zerolog"
tc "github.com/testcontainers/testcontainers-go"

Expand Down Expand Up @@ -58,8 +61,13 @@ var NaiveRetrier = func(l zerolog.Logger, startErr error, req tc.GenericContaine
Str("Retrier", "NaiveRetrier").
Msgf("Attempting to start %s container", req.Name)

oldName := req.Name
req.Name = req.Name + "-naive-retry"
req.Reuse = false // We need to force a new container to be created

removeErr := removeContainer(req)
if removeErr != nil {
l.Error().Err(removeErr).Msgf("Failed to remove %s container to initiate restart", req.Name)
return nil, removeErr
}

ct, err := tc.GenericContainer(testcontext.Get(nil), req)
if err == nil {
Expand All @@ -78,8 +86,6 @@ var NaiveRetrier = func(l zerolog.Logger, startErr error, req tc.GenericContaine
}
}

req.Name = oldName

l.Debug().
Str("Original start error", startErr.Error()).
Str("Current start error", err.Error()).
Expand All @@ -94,9 +100,8 @@ var LinuxPlatformImageRetrier = func(l zerolog.Logger, startErr error, req tc.Ge
if startErr == nil {
return nil, startErr
}

req.Reuse = false // We need to force a new container to be created
oldName := req.Name
req.Name = req.Name + "-linux-retry"

// a bit lame, but that's the lame error we get in case there's no specific image for our platform :facepalm:
if !strings.Contains(startErr.Error(), "No such image") {
Expand All @@ -115,6 +120,12 @@ var LinuxPlatformImageRetrier = func(l zerolog.Logger, startErr error, req tc.Ge
originalPlatform := req.ImagePlatform
req.ImagePlatform = "linux/x86_64"

removeErr := removeContainer(req)
if removeErr != nil {
l.Error().Err(removeErr).Msgf("Failed to remove %s container to initiate restart", req.Name)
return nil, removeErr
}

ct, err := tc.GenericContainer(testcontext.Get(nil), req)
if err == nil {
l.Debug().
Expand All @@ -124,7 +135,6 @@ var LinuxPlatformImageRetrier = func(l zerolog.Logger, startErr error, req tc.Ge
}

req.ImagePlatform = originalPlatform
req.Name = oldName

if ct != nil {
err := ct.Terminate(testcontext.Get(nil))
Expand Down Expand Up @@ -171,3 +181,18 @@ func StartContainerWithRetry(l zerolog.Logger, req tc.GenericContainerRequest, r

return nil, err
}

func removeContainer(req tc.GenericContainerRequest) error {
provider, providerErr := tc.NewDockerProvider()
if providerErr != nil {
return errors.Wrapf(providerErr, "failed to create Docker provider")
}

removeErr := provider.Client().ContainerRemove(context.Background(), req.Name, container.RemoveOptions{Force: true})
if removeErr != nil && strings.Contains(strings.ToLower(removeErr.Error()), "no such container") {
// container doesn't exist, nothing to remove
return nil
}

return removeErr
}
2 changes: 1 addition & 1 deletion wasp/benchspy/TO_DO.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Known things to do:
- [ ] add logger
- [x] add logger
- [x] add unit tests for prometheus
- [x] add wasp test for prometheus only
- [ ] add e2e OCRv2 test with CTFv2
Expand Down
19 changes: 12 additions & 7 deletions wasp/benchspy/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,27 @@ func NewStandardDirectQueryExecutor(generator *wasp.Generator) (*DirectQueryExec
// NewDirectQueryExecutor creates a new DirectQueryExecutor with the specified generator and query functions.
// It initializes the executor with a kind name and prepares a map for query results, enabling efficient query execution.
func NewDirectQueryExecutor(generator *wasp.Generator, queries map[string]DirectQueryFn) (*DirectQueryExecutor, error) {
L.Debug().
Str("Generator", generator.Cfg.GenName).
Int("Queries", len(queries)).
Msg("Creating new Direct query executor")

return &DirectQueryExecutor{
ex := &DirectQueryExecutor{
KindName: string(StandardQueryExecutor_Direct),
Generator: generator,
Queries: queries,
QueryResults: make(map[string]interface{}),
}, nil
}

L.Debug().
Str("Generator", ex.GeneratorName()).
Int("Queries", len(queries)).
Msg("Creating new Direct query executor")

return ex, nil
}

// GeneratorName returns the name of the generator associated with the query executor.
// It is useful for identifying and categorizing results based on their generator type.
func (g *DirectQueryExecutor) GeneratorName() string {
if g.Generator == nil {
return ""
}
return g.Generator.Cfg.GenName
}

Expand Down
2 changes: 0 additions & 2 deletions wasp/examples/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -872,8 +872,6 @@ github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.20-0.202501061
github.com/smartcontractkit/chainlink-testing-framework/lib v1.50.20-0.20250106135623-15722ca32b64/go.mod h1:ag7LEgejsVtPXaUNkcoFPpAoDkl1J8V2HSbqVUxfEtk=
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0 h1:VIxK8u0Jd0Q/VuhmsNm6Bls6Tb31H/sA3A/rbc5hnhg=
github.com/smartcontractkit/chainlink-testing-framework/lib/grafana v1.50.0/go.mod h1:lyAu+oMXdNUzEDScj2DXB2IueY+SDXPPfyl/kb63tMM=
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.4 h1:pmPPbbe0lJFIeA8wtV2VMy6k1UiS91H7ARFtLOuEh4I=
github.com/smartcontractkit/chainlink-testing-framework/wasp v1.50.4/go.mod h1:nWXWjJng+3OxuvrgJ0uWtryClTWaiTJjdko+DwGZcyo=
github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js=
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
github.com/sony/gobreaker v0.5.0 h1:dRCvqm0P490vZPmy7ppEk2qCnCieBooFJ+YoXGYB+yg=
Expand Down

0 comments on commit a7de13a

Please sign in to comment.