Skip to content

Commit

Permalink
Add ClNode.ExecGetVersion for E2E docker tests (#11691)
Browse files Browse the repository at this point in the history
* Add ExecGetVersion for Docker ClNode

* Fix lint
  • Loading branch information
lukaszcl authored Jan 5, 2024
1 parent 2f10153 commit 3ea324f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions integration-tests/docker/test_env/cl_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package test_env
import (
"context"
"fmt"
"io"
"maps"
"math/big"
"net/url"
"os"
"regexp"
"strings"
"testing"
"time"
Expand All @@ -15,6 +17,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/google/uuid"
"github.com/pelletier/go-toml/v2"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
tc "github.com/testcontainers/testcontainers-go"
Expand Down Expand Up @@ -361,6 +364,28 @@ func (n *ClNode) StartContainer() error {
return nil
}

func (n *ClNode) ExecGetVersion() (string, error) {
cmd := []string{"chainlink", "--version"}
_, output, err := n.Container.Exec(context.Background(), cmd)
if err != nil {
return "", errors.Wrapf(err, "could not execute cmd %s", cmd)
}
outputBytes, err := io.ReadAll(output)
if err != nil {
return "", err
}
outputString := strings.TrimSpace(string(outputBytes))

// Find version in cmd output
re := regexp.MustCompile("@(.*)")
matches := re.FindStringSubmatch(outputString)

if len(matches) > 1 {
return matches[1], nil
}
return "", errors.Errorf("could not find chainlink version in command output '%'", output)
}

func (n *ClNode) getContainerRequest(secrets string) (
*tc.ContainerRequest, error) {
configFile, err := os.CreateTemp("", "node_config")
Expand Down

0 comments on commit 3ea324f

Please sign in to comment.