Skip to content

Commit

Permalink
Log stream improvements (#11791)
Browse files Browse the repository at this point in the history
* use default docker hooks from CTF, pass logstream as functional option when creating a new container

* bump ctf

* use tagged ctf version

* use tagged CTF version

* use log stream from env component, not cl node
  • Loading branch information
Tofel authored Jan 19, 2024
1 parent 93deaf6 commit 0e50199
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 40 deletions.
25 changes: 1 addition & 24 deletions integration-tests/docker/test_env/cl_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ type ClNode struct {
UserEmail string `json:"userEmail"`
UserPassword string `json:"userPassword"`
AlwaysPullImage bool `json:"-"`
PostStartsHooks []tc.ContainerHook `json:"-"`
PostStopsHooks []tc.ContainerHook `json:"-"`
PreTerminatesHooks []tc.ContainerHook `json:"-"`
t *testing.T
l zerolog.Logger
ls *logstream.LogStream
}

type ClNodeOption = func(c *ClNode)
Expand Down Expand Up @@ -97,7 +93,7 @@ func WithDbContainerName(name string) ClNodeOption {

func WithLogStream(ls *logstream.LogStream) ClNodeOption {
return func(c *ClNode) {
c.ls = ls
c.LogStream = ls
}
}

Expand Down Expand Up @@ -150,25 +146,6 @@ func NewClNode(networks []string, imageName, imageVersion string, nodeConfig *ch
return n, nil
}

func (n *ClNode) SetDefaultHooks() {
n.PostStartsHooks = []tc.ContainerHook{
func(ctx context.Context, c tc.Container) error {
if n.ls != nil {
return n.ls.ConnectContainer(ctx, c, "cl-node")
}
return nil
},
}
n.PostStopsHooks = []tc.ContainerHook{
func(ctx context.Context, c tc.Container) error {
if n.ls != nil {
return n.ls.DisconnectContainer(c)
}
return nil
},
}
}

func (n *ClNode) SetTestLogger(t *testing.T) {
n.l = logging.GetTestLogger(t)
n.t = t
Expand Down
17 changes: 2 additions & 15 deletions integration-tests/docker/test_env/test_env.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package test_env

import (
"context"
"encoding/json"
"fmt"
"math/big"
Expand Down Expand Up @@ -66,7 +65,7 @@ func (te *CLClusterTestEnv) WithTestEnvConfig(cfg *TestEnvConfig) *CLClusterTest
te.Cfg = cfg
if cfg.MockAdapter.ContainerName != "" {
n := []string{te.Network.Name}
te.MockAdapter = test_env.NewKillgrave(n, te.Cfg.MockAdapter.ImpostersPath, test_env.WithContainerName(te.Cfg.MockAdapter.ContainerName))
te.MockAdapter = test_env.NewKillgrave(n, te.Cfg.MockAdapter.ImpostersPath, test_env.WithContainerName(te.Cfg.MockAdapter.ContainerName), test_env.WithLogStream(te.LogStream))
}
return te
}
Expand Down Expand Up @@ -154,7 +153,7 @@ func (te *CLClusterTestEnv) StartClCluster(nodeConfig *chainlink.Config, count i
if te.Cfg != nil && te.Cfg.ClCluster != nil {
te.ClCluster = te.Cfg.ClCluster
} else {
opts = append(opts, WithSecrets(secretsConfig))
opts = append(opts, WithSecrets(secretsConfig), WithLogStream(te.LogStream))
te.ClCluster = &ClCluster{}
for i := 0; i < count; i++ {
ocrNode, err := NewClNode([]string{te.Network.Name}, os.Getenv("CHAINLINK_IMAGE"), os.Getenv("CHAINLINK_VERSION"), nodeConfig, opts...)
Expand All @@ -172,18 +171,6 @@ func (te *CLClusterTestEnv) StartClCluster(nodeConfig *chainlink.Config, count i
}
}

if te.LogStream != nil {
for _, node := range te.ClCluster.Nodes {
node.ls = te.LogStream
}
if te.MockAdapter != nil {
err := te.LogStream.ConnectContainer(context.Background(), te.MockAdapter.Container, "mock-adapter")
if err != nil {
return err
}
}
}

// Start/attach node containers
return te.ClCluster.Start()
}
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/docker/test_env/test_env_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (b *CLTestEnvBuilder) Build() (*CLClusterTestEnv, error) {
return nil, fmt.Errorf("test environment builder failed: %w", fmt.Errorf("cannot start mock adapter without a network"))
}

b.te.MockAdapter = test_env.NewKillgrave([]string{b.te.Network.Name}, "")
b.te.MockAdapter = test_env.NewKillgrave([]string{b.te.Network.Name}, "", test_env.WithLogStream(b.te.LogStream))

err = b.te.StartMockAdapter()
if err != nil {
Expand Down

0 comments on commit 0e50199

Please sign in to comment.