Enable goimports and fix formatting. (#459)
This commit is contained in:
parent
ea6fc3c532
commit
db42772b4d
@ -21,7 +21,7 @@ linters:
|
||||
- deadcode # find code that is not used
|
||||
#TODO#- unparam # check for unused parameters
|
||||
- nakedret # check for naked returns
|
||||
# - goimports # fix import order
|
||||
- goimports # fix import order
|
||||
- misspell # check spelling
|
||||
- unconvert # remove unnecessary conversions
|
||||
#TODO#- maligned # check for better memory usage
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"storj.io/storj/pkg/auth/grpcauth"
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
"storj.io/storj/pkg/datarepair/checker"
|
||||
"storj.io/storj/pkg/datarepair/repairer"
|
||||
@ -21,7 +22,6 @@ import (
|
||||
"storj.io/storj/pkg/pointerdb"
|
||||
"storj.io/storj/pkg/process"
|
||||
"storj.io/storj/pkg/provider"
|
||||
"storj.io/storj/pkg/auth/grpcauth"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -134,7 +134,7 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
|
||||
setupCfg.ListenHost, startingPort+1),
|
||||
"uplink.minio-dir": filepath.Join(
|
||||
setupCfg.BasePath, "uplink", "minio"),
|
||||
"uplink.enc-key": setupCfg.EncKey,
|
||||
"uplink.enc-key": setupCfg.EncKey,
|
||||
"uplink.api-key": setupCfg.APIKey,
|
||||
"pointer-db.auth.api-key": setupCfg.APIKey,
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import (
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/storj/pkg/cfgstruct"
|
||||
"storj.io/storj/pkg/process"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/process"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
"strconv"
|
||||
|
||||
"github.com/loov/hrtime"
|
||||
|
||||
@ -81,35 +81,35 @@ func main() {
|
||||
log.Println("Creating files", bucket)
|
||||
// n files in one folder
|
||||
for k := 0; k < *listsize; k++ {
|
||||
err := client.Upload(bucket, "folder/data" + strconv.Itoa(k), data)
|
||||
err := client.Upload(bucket, "folder/data"+strconv.Itoa(k), data)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create file %q: %+v\n", "folder/data" + strconv.Itoa(k), err)
|
||||
log.Fatalf("failed to create file %q: %+v\n", "folder/data"+strconv.Itoa(k), err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("Creating folders", bucket)
|
||||
// n - 1 (one folder already exists) folders with one file in each folder
|
||||
for k := 0; k < *listsize - 1; k++ {
|
||||
err := client.Upload(bucket, "folder" + strconv.Itoa(k) + "/data", data)
|
||||
for k := 0; k < *listsize-1; k++ {
|
||||
err := client.Upload(bucket, "folder"+strconv.Itoa(k)+"/data", data)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create folder %q: %+v\n", "folder" + strconv.Itoa(k) + "/data", err)
|
||||
log.Fatalf("failed to create folder %q: %+v\n", "folder"+strconv.Itoa(k)+"/data", err)
|
||||
}
|
||||
}
|
||||
|
||||
defer func() {
|
||||
log.Println("Removing files")
|
||||
for k := 0; k < *listsize; k++ {
|
||||
err := client.Delete(bucket, "folder/data" + strconv.Itoa(k))
|
||||
err := client.Delete(bucket, "folder/data"+strconv.Itoa(k))
|
||||
if err != nil {
|
||||
log.Fatalf("failed to delete file %q: %+v\n", "folder/data" + strconv.Itoa(k), err)
|
||||
log.Fatalf("failed to delete file %q: %+v\n", "folder/data"+strconv.Itoa(k), err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println("Removing folders")
|
||||
for k := 0; k < *listsize - 1; k++ {
|
||||
err := client.Delete(bucket, "folder" + strconv.Itoa(k) + "/data")
|
||||
for k := 0; k < *listsize-1; k++ {
|
||||
err := client.Delete(bucket, "folder"+strconv.Itoa(k)+"/data")
|
||||
if err != nil {
|
||||
log.Fatalf("failed to delete folder %q: %+v\n", "folder" + strconv.Itoa(k) + "/data", err)
|
||||
log.Fatalf("failed to delete folder %q: %+v\n", "folder"+strconv.Itoa(k)+"/data", err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,11 +318,11 @@ func FileBenchmark(client Client, bucket string, filesize memory.Size, count int
|
||||
// ListBenchmark runs list buckets, folders and files benchmarks on bucket
|
||||
func ListBenchmark(client Client, bucket string, listsize int, count int, duration time.Duration) (Measurement, error) {
|
||||
log.Print("Benchmarking list")
|
||||
defer fmt.Println()
|
||||
measurement := Measurement{}
|
||||
defer fmt.Println()
|
||||
measurement := Measurement{}
|
||||
//measurement.Size = listsize
|
||||
for k := 0; k < count; k++ {
|
||||
{ // list folders
|
||||
{ // list folders
|
||||
start := hrtime.Now()
|
||||
result, err := client.ListObjects(bucket, "")
|
||||
if err != nil {
|
||||
@ -332,9 +332,9 @@ func ListBenchmark(client Client, bucket string, listsize int, count int, durati
|
||||
if len(result) != listsize {
|
||||
return measurement, fmt.Errorf("list folders result wrong: %+v", len(result))
|
||||
}
|
||||
measurement.Record("List Folders", finish-start)
|
||||
measurement.Record("List Folders", finish-start)
|
||||
}
|
||||
{ // list files
|
||||
{ // list files
|
||||
start := hrtime.Now()
|
||||
result, err := client.ListObjects(bucket, "folder")
|
||||
if err != nil {
|
||||
@ -344,10 +344,10 @@ func ListBenchmark(client Client, bucket string, listsize int, count int, durati
|
||||
if len(result) != listsize {
|
||||
return measurement, fmt.Errorf("list files result to low: %+v", len(result))
|
||||
}
|
||||
measurement.Record("List Files", finish-start)
|
||||
measurement.Record("List Files", finish-start)
|
||||
}
|
||||
}
|
||||
return measurement, nil
|
||||
return measurement, nil
|
||||
}
|
||||
|
||||
// Config is the setup for a particular client
|
||||
|
@ -13,13 +13,13 @@ import (
|
||||
|
||||
// "storj.io/storj/pkg/datarepair/repairer"
|
||||
// "storj.io/storj/pkg/datarepair/checker"
|
||||
"storj.io/storj/pkg/auth/grpcauth"
|
||||
"storj.io/storj/pkg/kademlia"
|
||||
"storj.io/storj/pkg/overlay"
|
||||
mockOverlay "storj.io/storj/pkg/overlay/mocks"
|
||||
"storj.io/storj/pkg/pointerdb"
|
||||
"storj.io/storj/pkg/process"
|
||||
"storj.io/storj/pkg/provider"
|
||||
"storj.io/storj/pkg/auth/grpcauth"
|
||||
"storj.io/storj/pkg/statdb"
|
||||
)
|
||||
|
||||
@ -40,9 +40,9 @@ var (
|
||||
}
|
||||
|
||||
runCfg struct {
|
||||
Identity provider.IdentityConfig
|
||||
Kademlia kademlia.Config
|
||||
PointerDB pointerdb.Config
|
||||
Identity provider.IdentityConfig
|
||||
Kademlia kademlia.Config
|
||||
PointerDB pointerdb.Config
|
||||
// Checker checker.Config
|
||||
// Repairer repairer.Config
|
||||
Overlay overlay.Config
|
||||
|
@ -14,13 +14,13 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/datarepair/queue"
|
||||
"storj.io/storj/pkg/dht"
|
||||
"storj.io/storj/pkg/node"
|
||||
"storj.io/storj/pkg/overlay"
|
||||
"storj.io/storj/pkg/overlay/mocks"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/pointerdb"
|
||||
"storj.io/storj/storage/redis"
|
||||
"storj.io/storj/storage/redis/redisserver"
|
||||
|
@ -113,82 +113,82 @@ func TestAddNode(t *testing.T) {
|
||||
nodeIDs: [][]string{{}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: "?O",
|
||||
node: mockNode("?O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{{63, 255}, {79, 255}, {95, 255},{127, 255}, {255, 255}},
|
||||
nodeIDs: [][]string{{"?O"},{"LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode("?O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{{63, 255}, {79, 255}, {95, 255}, {127, 255}, {255, 255}},
|
||||
nodeIDs: [][]string{{"?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: ">O",
|
||||
node: mockNode(">O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{">O", "?O"},{"LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode(">O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{">O", "?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: "=O",
|
||||
node: mockNode("=O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"=O", ">O", "?O"},{"LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode("=O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"=O", ">O", "?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: ";O",
|
||||
node: mockNode(";O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{";O", "=O", ">O", "?O"},{"LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode(";O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{";O", "=O", ">O", "?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: ":O",
|
||||
node: mockNode(":O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{":O", ";O", "=O", ">O", "?O"},{"LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode(":O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{":O", ";O", "=O", ">O", "?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: "9O",
|
||||
node: mockNode("9O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"},{"LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode("9O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: "8O: should drop",
|
||||
node: mockNode("8O"),
|
||||
added: false,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode("8O"),
|
||||
added: false,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: "KO",
|
||||
node: mockNode("KO"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"},{"KO", "LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode("KO"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"KO", "LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: "JO",
|
||||
node: mockNode("JO"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"},{"JO", "KO", "LO", "MO", "NO", "OO"},{"PO", "QO", "SO"},{},{}},
|
||||
node: mockNode("JO"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"JO", "KO", "LO", "MO", "NO", "OO"}, {"PO", "QO", "SO"}, {}, {}},
|
||||
},
|
||||
{testID: "]O",
|
||||
node: mockNode("]O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"},{"JO", "KO", "LO", "MO", "NO", "OO"},{"PO", "QO", "SO", "]O"},{},{}},
|
||||
node: mockNode("]O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"JO", "KO", "LO", "MO", "NO", "OO"}, {"PO", "QO", "SO", "]O"}, {}, {}},
|
||||
},
|
||||
{testID: "^O",
|
||||
node: mockNode("^O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"},{"JO", "KO", "LO", "MO", "NO", "OO"},{"PO", "QO", "SO", "]O", "^O"},{},{}},
|
||||
node: mockNode("^O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"JO", "KO", "LO", "MO", "NO", "OO"}, {"PO", "QO", "SO", "]O", "^O"}, {}, {}},
|
||||
},
|
||||
{testID: "_O",
|
||||
node: mockNode("_O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"},{"JO", "KO", "LO", "MO", "NO", "OO"},{"PO", "QO", "SO", "]O", "^O", "_O"},{},{}},
|
||||
node: mockNode("_O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"JO", "KO", "LO", "MO", "NO", "OO"}, {"PO", "QO", "SO", "]O", "^O", "_O"}, {}, {}},
|
||||
},
|
||||
{testID: "@O: split bucket 2",
|
||||
node: mockNode("@O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{71, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"},{"@O"},{"JO", "KO", "LO", "MO", "NO", "OO"},{"PO", "QO", "SO", "]O", "^O", "_O"},{},{}},
|
||||
node: mockNode("@O"),
|
||||
added: true,
|
||||
kadIDs: [][]byte{[]byte{63, 255}, []byte{71, 255}, []byte{79, 255}, []byte{95, 255}, []byte{127, 255}, []byte{255, 255}},
|
||||
nodeIDs: [][]string{{"9O", ":O", ";O", "=O", ">O", "?O"}, {"@O"}, {"JO", "KO", "LO", "MO", "NO", "OO"}, {"PO", "QO", "SO", "]O", "^O", "_O"}, {}, {}},
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
|
@ -18,13 +18,12 @@ import (
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/pkg/paths"
|
||||
"storj.io/storj/pkg/pb"
|
||||
"storj.io/storj/pkg/storage/meta"
|
||||
"storj.io/storj/pkg/auth"
|
||||
"storj.io/storj/storage"
|
||||
"storj.io/storj/storage/teststore"
|
||||
|
||||
)
|
||||
|
||||
func TestServicePut(t *testing.T) {
|
||||
@ -173,7 +172,7 @@ func TestServiceList(t *testing.T) {
|
||||
}
|
||||
|
||||
type Test struct {
|
||||
APIKey string
|
||||
APIKey string
|
||||
Request pb.ListRequest
|
||||
Expected *pb.ListResponse
|
||||
Error func(i int, err error)
|
||||
@ -217,8 +216,8 @@ func TestServiceList(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}, {
|
||||
APIKey: "wrong key",
|
||||
Request: pb.ListRequest{Recursive: true, MetaFlags: meta.All},//, APIKey: []byte("wrong key")},
|
||||
APIKey: "wrong key",
|
||||
Request: pb.ListRequest{Recursive: true, MetaFlags: meta.All}, //, APIKey: []byte("wrong key")},
|
||||
Error: errorWithCode(codes.Unauthenticated),
|
||||
}, {
|
||||
Request: pb.ListRequest{Recursive: true, Limit: 3},
|
||||
|
Loading…
Reference in New Issue
Block a user