Skip to content

Commit

Permalink
Merge branch 'sprint-1.10' into tokenomics_suite_merge
Browse files Browse the repository at this point in the history
  • Loading branch information
stewartie4 authored Sep 5, 2023
2 parents d5851e4 + aaf8bba commit 855af89
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 44 deletions.
36 changes: 18 additions & 18 deletions .github/workflows/nightly-cypress-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ jobs:
cd web-apps
docker build -f ./packages/bolt/docker/dockerfile . -t ${{ secrets.BOLT_REGISTRY }}:latest
echo $TAG-$SHORT_SHA
echo "COMMIT_TAG=$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
echo "COMMIT_TAG=dev9-$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
docker tag ${{ secrets.BOLT_REGISTRY }}:latest ${{ secrets.BOLT_REGISTRY }}:$TAG-$SHORT_SHA
docker push ${{ secrets.BOLT_REGISTRY }}:$TAG-$SHORT_SHA
docker tag ${{ secrets.BOLT_REGISTRY }}:latest ${{ secrets.BOLT_REGISTRY }}:dev9-$TAG-$SHORT_SHA
docker push ${{ secrets.BOLT_REGISTRY }}:dev9-$TAG-$SHORT_SHA
- name: Clean Up The Workspace.
if: ${{ always() }}
Expand Down Expand Up @@ -298,10 +298,10 @@ jobs:
cd web-apps
docker build -f ./packages/explorer/docker/dockerfile . -t ${{ secrets.ATLUS_REGISTRY }}:latest
echo $TAG-$SHORT_SHA
echo "COMMIT_TAG=$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
echo "COMMIT_TAG=dev9-$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
docker tag ${{ secrets.ATLUS_REGISTRY }}:latest ${{ secrets.ATLUS_REGISTRY }}:$TAG-$SHORT_SHA
docker push ${{ secrets.ATLUS_REGISTRY }}:$TAG-$SHORT_SHA
docker tag ${{ secrets.ATLUS_REGISTRY }}:latest ${{ secrets.ATLUS_REGISTRY }}:dev9-$TAG-$SHORT_SHA
docker push ${{ secrets.ATLUS_REGISTRY }}:dev9-$TAG-$SHORT_SHA
- name: Clean Up The Workspace.
if: ${{ always() }}
Expand Down Expand Up @@ -497,10 +497,10 @@ jobs:
cd web-apps
docker build -f ./packages/chalk/docker/dockerfile . -t ${{ secrets.ZNFT_REGISTRY }}:latest
echo $TAG-$SHORT_SHA
echo "COMMIT_TAG=$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
echo "COMMIT_TAG=dev9-$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
docker tag ${{ secrets.ZNFT_REGISTRY }}:latest ${{ secrets.ZNFT_REGISTRY }}:$TAG-$SHORT_SHA
docker push ${{ secrets.ZNFT_REGISTRY }}:$TAG-$SHORT_SHA
docker tag ${{ secrets.ZNFT_REGISTRY }}:latest ${{ secrets.ZNFT_REGISTRY }}:dev9-$TAG-$SHORT_SHA
docker push ${{ secrets.ZNFT_REGISTRY }}:dev9-$TAG-$SHORT_SHA
- name: Clean Up The Workspace.
if: ${{ always() }}
Expand Down Expand Up @@ -697,10 +697,10 @@ jobs:
cd web-apps
docker build -f ./packages/chimney/docker/dockerfile . -t ${{ secrets.CHIMNEY_REGISTRY }}:latest
echo $TAG-$SHORT_SHA
echo "COMMIT_TAG=$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
echo "COMMIT_TAG=dev9-$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
docker tag ${{ secrets.CHIMNEY_REGISTRY }}:latest ${{ secrets.CHIMNEY_REGISTRY }}:$TAG-$SHORT_SHA
docker push ${{ secrets.CHIMNEY_REGISTRY }}:$TAG-$SHORT_SHA
docker tag ${{ secrets.CHIMNEY_REGISTRY }}:latest ${{ secrets.CHIMNEY_REGISTRY }}:dev9-$TAG-$SHORT_SHA
docker push ${{ secrets.CHIMNEY_REGISTRY }}:dev9-$TAG-$SHORT_SHA
- name: Clean Up The Workspace.
if: ${{ always() }}
Expand Down Expand Up @@ -896,10 +896,10 @@ jobs:
cd web-apps
docker build -f ./packages/blimp/docker/dockerfile . -t ${{ secrets.BLIMP_REGISTRY }}:latest
echo $TAG-$SHORT_SHA
echo "COMMIT_TAG=$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
echo "COMMIT_TAG=dev9-$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
docker tag ${{ secrets.BLIMP_REGISTRY }}:latest ${{ secrets.BLIMP_REGISTRY }}:$TAG-$SHORT_SHA
docker push ${{ secrets.BLIMP_REGISTRY }}:$TAG-$SHORT_SHA
docker tag ${{ secrets.BLIMP_REGISTRY }}:latest ${{ secrets.BLIMP_REGISTRY }}:dev9-$TAG-$SHORT_SHA
docker push ${{ secrets.BLIMP_REGISTRY }}:dev9-$TAG-$SHORT_SHA
- name: Clean Up The Workspace.
if: ${{ always() }}
Expand Down Expand Up @@ -1095,10 +1095,10 @@ jobs:
cd web-apps
docker build -f ./packages/vult/docker/dockerfile . -t ${{ secrets.VULT_REGISTRY }}:latest
echo $TAG-$SHORT_SHA
echo "COMMIT_TAG=$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
echo "COMMIT_TAG=dev9-$TAG-$SHORT_SHA" >>$GITHUB_OUTPUT
docker tag ${{ secrets.VULT_REGISTRY }}:latest ${{ secrets.VULT_REGISTRY }}:$TAG-$SHORT_SHA
docker push ${{ secrets.VULT_REGISTRY }}:$TAG-$SHORT_SHA
docker tag ${{ secrets.VULT_REGISTRY }}:latest ${{ secrets.VULT_REGISTRY }}:dev9-$TAG-$SHORT_SHA
docker push ${{ secrets.VULT_REGISTRY }}:dev9-$TAG-$SHORT_SHA
- name: Clean Up The Workspace.
if: ${{ always() }}
Expand Down
34 changes: 31 additions & 3 deletions internal/cli/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ func RunCommandWithoutRetry(commandString string) ([]string, error) {

sanitizedArgs := sanitizeArgs(args)
rawOutput, err := executeCommand(commandName, sanitizedArgs)

Logger.Debugf("Command [%v] exited with error [%v] and output [%v]", commandString, err, sanitizeOutput(rawOutput))
var commandStringForLog string

// Redact keys before logging
if strings.Contains(commandString, "--access-key") {
index := strings.Index(commandString, "--access-key")
// get next single word after "--access-key"
accessKey := strings.Fields(commandString[index:])[1]
commandStringForLog = strings.ReplaceAll(commandString, accessKey, "****")
}
if strings.Contains(commandString, "--secret-key") {
index := strings.Index(commandString, "--secret-key")
// get next single word after "--secret-key"
secretKey := strings.Fields(commandString[index:])[1]
commandStringForLog = strings.ReplaceAll(commandString, secretKey, "****")
}
Logger.Debugf("Command [%v] exited with error [%v] and output [%v]", commandStringForLog, err, sanitizeOutput(rawOutput))

return sanitizeOutput(rawOutput), err
}
Expand All @@ -52,6 +66,7 @@ func RunCommand(t *test.SystemTest, commandString string, maxAttempts int, backo
red := "\033[31m"
yellow := "\033[33m"
green := "\033[32m"
var commandStringForLog string

var count int
for {
Expand All @@ -67,7 +82,20 @@ func RunCommand(t *test.SystemTest, commandString string, maxAttempts int, backo
t.Logf("%sCommand failed on attempt [%v/%v] due to error [%v]. Output: [%v]\n", yellow, count, maxAttempts, err, strings.Join(output, " -<NEWLINE>- "))
time.Sleep(backoff)
} else {
t.Logf("%sCommand failed on final attempt [%v/%v] due to error [%v]. Command String: [%v] Output: [%v]\n", red, count, maxAttempts, err, commandString, strings.Join(output, " -<NEWLINE>- "))
// Redact keys before logging
if strings.Contains(commandString, "--access-key") {
index := strings.Index(commandString, "--access-key")
// get next single word after "--access-key"
accessKey := strings.Fields(commandString[index:])[1]
commandStringForLog = strings.ReplaceAll(commandString, accessKey, "****")
}
if strings.Contains(commandString, "--secret-key") {
index := strings.Index(commandString, "--secret-key")
// get next single word after "--secret-key"
secretKey := strings.Fields(commandString[index:])[1]
commandStringForLog = strings.ReplaceAll(commandString, secretKey, "****")
}
t.Logf("%sCommand failed on final attempt [%v/%v] due to error [%v]. Command String: [%v] Output: [%v]\n", red, count, maxAttempts, err, commandStringForLog, strings.Join(output, " -<NEWLINE>- "))

if err != nil {
t.Logf("%sThe verbose output for the command is:", red)
Expand Down
4 changes: 3 additions & 1 deletion tests/cli_tests/0_s3mgrt_migrate_alternate2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ func Test0S3MigrationAlternatePart2(testSetup *testing.T) {
// This func needs to be in sync with the original func.
func getUniqueShortObjKey(objectKey string) string {
// Max length to which objectKey would be trimmed to.
const maxLength = 100
// Keeping this less than 100 chars to prevent longer name in case of uploading duplicate
// files with `_copy` suffixes.
const maxLength = 90

if len(objectKey) > maxLength {
// Generate a SHA-1 hash of the object key
Expand Down
2 changes: 1 addition & 1 deletion tests/cli_tests/config/zbox_config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
block_worker: https://demo.zus.network/dns
block_worker: https://dev.zus.network/dns
confirmation_chain_length: 3
ethereum_node_url: "https://rpc.tenderly.co/fork/dcf1ae29-309c-41e1-ae3d-7f66bc814b82"
min_confirmation: 50
Expand Down
10 changes: 5 additions & 5 deletions tests/cli_tests/zboxcli_create_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ func TestCreateDir(testSetup *testing.T) {
output, err := createDir(t, configPath, allocID, longDirName, false)
require.NotNil(t, err, "expected create dir failure command executed with output: ", strings.Join(output, "\n"))
require.Len(t, output, 1)
aggregatedOutput := strings.ToLower(strings.Join(output, " "))
require.Contains(t, aggregatedOutput, "directory creation failed")
require.Contains(t, aggregatedOutput, "consensus not met")
aggregatedOutput := strings.Join(output, " ")
require.Contains(t, aggregatedOutput, "Directory creation failed")
require.Contains(t, aggregatedOutput, "consensus_not_met")

output, err = listAll(t, configPath, allocID, true)
require.Nil(t, err, "Unexpected list all failure %s", strings.Join(output, "\n"))
Expand Down Expand Up @@ -238,7 +238,7 @@ func TestCreateDir(testSetup *testing.T) {
output, err := createDirForWallet(t, configPath, wallet, true, allocID, true, "", false)
require.NotNil(t, err, "Expecting create dir failure %s", strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Equal(t, "CreateDir failed: invalid_name: Invalid name for dir", output[0])
require.Equal(t, "Directory creation failed. invalid_path: Path is not absolute", output[0])
})

t.Run("create attempt with missing allocation", func(t *test.SystemTest) {
Expand Down Expand Up @@ -298,7 +298,7 @@ func TestCreateDir(testSetup *testing.T) {
require.NotNil(t, err, "Expected create dir failure but got output: ", strings.Join(output, "\n"))
require.Len(t, output, 1)
aggregatedOutput := strings.Join(output, " ")
require.Contains(t, aggregatedOutput, `consensus not met`)
require.Contains(t, aggregatedOutput, `consensus_not_met`)
})
}

Expand Down
8 changes: 4 additions & 4 deletions tests/cli_tests/zboxcli_file_copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func TestFileCopy(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "copy_failed")
require.Contains(t, output[0], "Copy failed")

// list-all
output, err = listAll(t, configPath, allocationID, true)
Expand Down Expand Up @@ -436,7 +436,7 @@ func TestFileCopy(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "copy_failed")
require.Contains(t, output[0], "Copy failed")

// list-all
output, err = listAll(t, configPath, allocationID, true)
Expand Down Expand Up @@ -486,7 +486,7 @@ func TestFileCopy(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "copy_failed")
require.Contains(t, output[0], "Copy failed")
})

t.Run("copy file from someone else's allocation should fail", func(t *test.SystemTest) {
Expand Down Expand Up @@ -531,7 +531,7 @@ func TestFileCopy(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "copy_failed")
require.Contains(t, output[0], "Copy failed")

// list-all
output, err = listAll(t, configPath, allocationID, true)
Expand Down
8 changes: 4 additions & 4 deletions tests/cli_tests/zboxcli_file_move_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func TestFileMove(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "move_failed")
require.Contains(t, output[0], "Move failed")

// list-all
output, err = listAll(t, configPath, allocationID, true)
Expand Down Expand Up @@ -425,7 +425,7 @@ func TestFileMove(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "move_failed")
require.Contains(t, output[0], "Move failed")

// list-all
output, err = listAll(t, configPath, allocationID, true)
Expand Down Expand Up @@ -475,7 +475,7 @@ func TestFileMove(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "move_failed")
require.Contains(t, output[0], "Move failed")
})

t.Run("move file from someone else's allocation should fail", func(t *test.SystemTest) {
Expand Down Expand Up @@ -520,7 +520,7 @@ func TestFileMove(testSetup *testing.T) { // nolint:gocyclo // team preference i
}, true)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "move_failed")
require.Contains(t, output[0], "Move failed")

// list-all
output, err = listAll(t, configPath, allocationID, true)
Expand Down
8 changes: 4 additions & 4 deletions tests/cli_tests/zboxcli_file_rename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func TestFileRename(testSetup *testing.T) { // nolint:gocyclo // team preference
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Equal(t, "invalid_operation: cannot rename root path", output[0])
require.Equal(t, "Rename failed. invalid_operation: cannot rename root path", output[0])
}) //todo: too slow

t.Run("rename non-existing file should fail", func(t *test.SystemTest) {
Expand All @@ -531,7 +531,7 @@ func TestFileRename(testSetup *testing.T) { // nolint:gocyclo // team preference
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "rename_failed")
require.Contains(t, output[0], "Rename failed")
})

t.Run("rename file from someone else's allocation should fail", func(t *test.SystemTest) {
Expand Down Expand Up @@ -577,7 +577,7 @@ func TestFileRename(testSetup *testing.T) { // nolint:gocyclo // team preference
})
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Contains(t, output[0], "rename_failed")
require.Contains(t, output[0], "Rename failed")

// list-all
output, err = listAll(t, configPath, allocationID, true)
Expand Down Expand Up @@ -735,7 +735,7 @@ func TestFileRename(testSetup *testing.T) { // nolint:gocyclo // team preference
}, true)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Equal(t, "this options for this file is not permitted for this allocation", output[0])
require.Equal(t, output[0], "Rename failed. this options for this file is not permitted for this allocation")

output, err = listFilesInAllocation(t, configPath, createParams(map[string]interface{}{
"allocation": allocationID,
Expand Down
9 changes: 5 additions & 4 deletions tests/cli_tests/zboxcli_file_upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ func TestUpload(testSetup *testing.T) {
})

thumbnail := escapedTestName(t) + "thumbnail.png"
_ = generateThumbnail(t, thumbnail) // nolint

filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
Expand Down Expand Up @@ -542,7 +543,7 @@ func TestUpload(testSetup *testing.T) {
"localpath": filename,
}, false)
require.Nil(t, err, strings.Join(output, "\n"))
require.False(t, strings.Contains(strings.Join(output, "\n"), "upload_failed"), strings.Join(output, "\n"))
require.False(t, strings.Contains(strings.Join(output, "\n"), "Upload failed"), strings.Join(output, "\n"))
})

t.Run("Upload File to Existing File Should Fail", func(t *test.SystemTest) {
Expand Down Expand Up @@ -578,7 +579,7 @@ func TestUpload(testSetup *testing.T) {
"localpath": filename,
})
require.NotNil(t, err, strings.Join(output, "\n"))
require.True(t, strings.Contains(strings.Join(output, ""), "upload_failed"), strings.Join(output, "\n"))
require.True(t, strings.Contains(strings.Join(output, ""), "Upload failed"), strings.Join(output, "\n"))
})

t.Run("Upload File to Non-Existent Allocation Should Fail", func(t *test.SystemTest) {
Expand Down Expand Up @@ -648,7 +649,7 @@ func TestUpload(testSetup *testing.T) {

require.NotNil(t, err, strings.Join(output, "\n"))
require.True(t,
strings.Contains(strings.Join(output, ""), "upload_failed"), strings.Join(output, "\n"))
strings.Contains(strings.Join(output, ""), "Upload failed"), strings.Join(output, "\n"))
})

t.Run("Upload Non-Existent File Should Fail", func(t *test.SystemTest) {
Expand Down Expand Up @@ -995,7 +996,7 @@ func TestUpload(testSetup *testing.T) {
"allocation": allocationID,
"remotepath": "/",
"localpath": "./" + videoName + "." + videoFormat,
"web-streaming": "",
"web-streaming": true,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
Expand Down

0 comments on commit 855af89

Please sign in to comment.