Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed Apr 13, 2024
1 parent 3990b69 commit c124edc
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Expand Up @@ -26,7 +26,9 @@ jobs:
go-version: "1.22"
check-latest: true
cache: true
cache-dependency-path: go.sum
cache-dependency-path: |
simapp/go.sum
systemtest/go.sum
- uses: technote-space/get-diff-action@v6.1.2
id: git_diff
with:
Expand Down
14 changes: 11 additions & 3 deletions systemtests/system.go
Expand Up @@ -528,14 +528,22 @@ func (s *SystemUnderTest) ForEachNodeExecAndWait(t *testing.T, cmds ...[]string)
}

func runShellCmd(t *testing.T, cmd string, args ...string) string {
out, err := runShellCmdX(cmd, args...)
require.NoError(t, err)
return out
}

func runShellCmdX(cmd string, args ...string) (string, error) {
c := exec.Command( //nolint:gosec
locateExecutable(cmd),
args...,
)

Check failure

Code scanning / gosec

Subprocess launched with variable Error

Subprocess launched with a potential tainted input or cmd arguments
c.Dir = WorkDir
out, err := c.CombinedOutput()
require.NoError(t, err, "exec %q: %s", cmd, string(out))
return string(out)
if err != nil {
return string(out), fmt.Errorf("run `%s %s`: out: %s: %w", cmd, strings.Join(args, " "), string(out), err)
}
return string(out), nil
}

// startNodesAsync runs the given app cli command for all cluster nodes and returns without waiting
Expand Down Expand Up @@ -727,7 +735,7 @@ func locateExecutable(file string) string {
panic(fmt.Sprintf("unexpected error with file %q: %s", file, err.Error()))
}
if path == "" {
panic(fmt.Sprintf("%q not founc", file))
panic(fmt.Sprintf("%q not found", file))
}
return path
}
Expand Down
25 changes: 18 additions & 7 deletions systemtests/testnet_init.go
Expand Up @@ -96,13 +96,24 @@ func (s LegacyTestnetInitializer) Initialize() {
"--minimum-gas-prices=" + s.minGasPrice,
}
fmt.Printf("+++ %s %s\n", s.execBinary, strings.Join(args, " "))
cmd := exec.Command( //nolint:gosec
locateExecutable(s.execBinary),
args...,
)
cmd.Dir = s.workDir
out := mustV(cmd.CombinedOutput())
s.log(string(out))
executable := locateExecutable(s.execBinary)

Check warning

Code scanning / CodeQL

Useless assignment to local variable Warning

This definition of executable is never used.
out, err := runShellCmdX("ls", "-la", "/home/runner/work/cosmos-sdk/cosmos-sdk/systemtests/binaries")
if err != nil {
panic(err)
}
fmt.Println("+++ debug: " + out)
executable = locateExecutable(s.execBinary)
out, err = runShellCmdX(s.execBinary, "version")
if err != nil {
panic(err)
}
fmt.Println(out)

out, err = runShellCmdX(executable, args...)
if err != nil {
panic(err)
}
fmt.Println(out)

nodeAddresses := make([]string, s.initialNodesCount)
for i := 0; i < s.initialNodesCount; i++ {
Expand Down
7 changes: 5 additions & 2 deletions systemtests/upgrade_test.go
Expand Up @@ -21,6 +21,7 @@ func TestChainUpgrade(t *testing.T) {
// start a legacy chain with some state
// when a chain upgrade proposal is executed
// then the chain upgrades successfully
sut.StopChain()

legacyBinary := FetchExecutable(t, "v0.50")
t.Logf("+++ legacy binary: %s\n", legacyBinary)
Expand Down Expand Up @@ -99,14 +100,16 @@ func FetchExecutable(t *testing.T, version string) string {
panic(err)
}

cacheFile := filepath.Join(cacheFolder, fmt.Sprintf("%s_%s", execBinaryName, version))
cacheFile := filepath.Join(cacheFolder, fmt.Sprintf("%s_alx", execBinaryName))
//cacheFile := filepath.Join(cacheFolder, fmt.Sprintf("%s_%s", execBinaryName, version))
if _, err := os.Stat(cacheFile); err == nil {
return cacheFile
}
destFile := filepath.Join(cacheFolder, "simd_"+version)
destFile := cacheFile
t.Log("+++ version not in cache, downloading from docker image")
runShellCmd(t, "docker", "pull", "ghcr.io/cosmos/simapp:"+version)
runShellCmd(t, "docker", "create", "--name=ci_temp", "ghcr.io/cosmos/simapp:"+version)
runShellCmd(t, "docker", "cp", "ci_temp:/usr/bin/simd", destFile)
t.Logf("ls %q: %s\n", cacheFolder, runShellCmd(t, "ls", "-la", cacheFolder))
return destFile
}

0 comments on commit c124edc

Please sign in to comment.