Skip to content

Commit

Permalink
More dead code and code style
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder committed Sep 20, 2023
1 parent 3868aaa commit 7c30a86
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 38 deletions.
4 changes: 2 additions & 2 deletions esti/gc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func prepareForGC(t *testing.T, ctx context.Context, testCase *testCase, blockst
t.Fatalf("Commit some data %s", err)
}
commit := commitRes.JSON201
commitId := commit.Id
commitID := commit.Id

_, err = client.CreateBranchWithResponse(ctx, repo, apigen.CreateBranchJSONRequestBody{Name: "b" + testCase.id, Source: newBranch})
if err != nil {
Expand Down Expand Up @@ -291,7 +291,7 @@ func prepareForGC(t *testing.T, ctx context.Context, testCase *testCase, blockst
}
}
}
return commitId
return commitID
}

func validateGCJob(t *testing.T, ctx context.Context, testCase *testCase, existingRef string) {
Expand Down
26 changes: 0 additions & 26 deletions esti/lakectl_util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package esti

import (
"context"
"errors"
"flag"
"fmt"
Expand All @@ -12,7 +11,6 @@ import (
"strconv"
"strings"
"testing"
"time"

"github.com/spf13/viper"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -66,19 +64,6 @@ func runShellCommand(t *testing.T, command string, isTerminal bool) ([]byte, err
return cmd.CombinedOutput()
}

func runShellCommandWithTimeout(t *testing.T, command string, isTerminal bool, timeout time.Duration) ([]byte, error) {
t.Helper()
t.Logf("Run shell command '%s' with timeout of '%d'", command, timeout)
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
// Assuming linux. Not sure if this is correct
cmd := exec.CommandContext(ctx, "/bin/sh", "-c", command)
cmd.Env = append(os.Environ(),
"LAKECTL_INTERACTIVE="+strconv.FormatBool(isTerminal),
)
return cmd.CombinedOutput()
}

// expandVariables receives a string with (possibly) variables in the form of {VAR_NAME}, and
// a var-name -> value mapping. It attempts to replace all occurrences of all variables with
// the corresponding values from the map. If all variables in the string has their mapping
Expand Down Expand Up @@ -220,17 +205,6 @@ func runCmd(t *testing.T, cmd string, expectFail bool, isTerminal bool, vars map
return sanitize(string(result), vars)
}

func runCmdWithTimeout(t *testing.T, cmd string, expectFail bool, isTerminal bool, vars map[string]string, timeout time.Duration) string {
t.Helper()
result, err := runShellCommandWithTimeout(t, cmd, isTerminal, timeout)
if expectFail {
require.Errorf(t, err, "Expected error in '%s' command did not occur. Output: %s", cmd, string(result))
} else {
require.NoErrorf(t, err, "Failed to run '%s' command - %s", cmd, string(result))
}
return sanitize(string(result), vars)
}

func runCmdAndVerifyResult(t *testing.T, cmd string, expectFail bool, isTerminal bool, expected string, vars map[string]string) {
t.Helper()
expanded, err := expandVariables(expected, vars)
Expand Down
19 changes: 10 additions & 9 deletions esti/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,23 @@ func uploadFileRandomDataAndReport(ctx context.Context, repo, branch, objPath st
}

func uploadFileAndReport(ctx context.Context, repo, branch, objPath, objContent string, direct bool) (checksum string, err error) {
// Upload using direct access
if direct {
stats, err := uploadContentDirect(ctx, client, repo, branch, objPath, nil, "", strings.NewReader(objContent))
if err != nil {
return "", err
}
return stats.Checksum, nil
} else {
resp, err := uploadContent(ctx, repo, branch, objPath, objContent)
if err != nil {
return "", err
}
if err := verifyResponse(resp.HTTPResponse, resp.Body); err != nil {
return "", err
}
return resp.JSON201.Checksum, nil
}
// Upload using API
resp, err := uploadContent(ctx, repo, branch, objPath, objContent)
if err != nil {
return "", err
}
if err := verifyResponse(resp.HTTPResponse, resp.Body); err != nil {
return "", err
}
return resp.JSON201.Checksum, nil
}

// uploadContentDirect uploads contents as a file using client-side ("direct") access to underlying storage.
Expand Down
2 changes: 1 addition & 1 deletion esti/ugc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func getReportCutoffTime(ctx context.Context, s3Client *s3.Client, bucket, repor
myFileContentAsString := buf.String()

type Report struct {
RunId string `json:"run_id"`
RunID string `json:"run_id"`
Success bool `json:"success"`
FirstSlice string `json:"first_slice"`
StartTime time.Time `json:"start_time"`
Expand Down

0 comments on commit 7c30a86

Please sign in to comment.