uplink: make ul/uplink consistent (#286)

* uplink: make ul/uplink consistent

* pstore: make test more robust
This commit is contained in:
JT Olio 2018-08-24 14:02:42 -06:00 committed by GitHub
parent 4edba19986
commit 560e9fd9ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 20 deletions

View File

@ -109,7 +109,7 @@ storage-node-image:
docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/storage-node:${TAG} -f cmd/farmer/Dockerfile .
.PHONY: uplink-image
uplink-image:
docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/uplink:${TAG} -f cmd/ul/Dockerfile .
docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/uplink:${TAG} -f cmd/uplink/Dockerfile .
.PHONY: all-in-one
all-in-one:

View File

@ -6,7 +6,7 @@ RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
WORKDIR /go/src/storj.io/storj
COPY . .
RUN dep ensure -vendor-only
RUN go build -o uplink cmd/ul/*.go
RUN go build -o uplink cmd/uplink/*.go
# final stage
FROM alpine
@ -17,5 +17,5 @@ EXPOSE 7777
WORKDIR /app
COPY --from=build-env /go/src/storj.io/storj/uplink /app/
COPY cmd/ul/entrypoint /entrypoint
COPY cmd/uplink/entrypoint /entrypoint
ENTRYPOINT ["/entrypoint"]

View File

@ -6,12 +6,12 @@ Usage:
First make an identity:
```
go install storj.io/storj/cmd/ul
ul setup
go install storj.io/storj/cmd/uplink
uplink setup
```
You can edit `~/.storj/ul/config.yaml` to your liking. Then run it!
You can edit `~/.storj/uplink/config.yaml` to your liking. Then run it!
```
ul run
uplink run
```

View File

@ -18,7 +18,7 @@ import (
var (
rootCmd = &cobra.Command{
Use: "ul",
Use: "uplink",
Short: "Uplink",
}
runCmd = &cobra.Command{
@ -43,7 +43,7 @@ var (
APIKey string `default:"" help:"the api key to use for the satellite"`
}
defaultConfDir = "$HOME/.storj/ul"
defaultConfDir = "$HOME/.storj/uplink"
)
func init() {
@ -65,7 +65,7 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
_, err = os.Stat(setupCfg.BasePath)
if !setupCfg.Overwrite && err == nil {
fmt.Println("A ul configuration already exists. Rerun with --overwrite")
fmt.Println("An uplink configuration already exists. Rerun with --overwrite")
return nil
}

View File

@ -49,7 +49,6 @@ func writeFileToDir(name, dir string) error {
func TestPiece(t *testing.T) {
TS := NewTestServer()
TS.Start()
defer TS.Stop()
if err := writeFileToDir("11111111111111111111", TS.s.DataDir); err != nil {
@ -120,7 +119,6 @@ func TestPiece(t *testing.T) {
func TestRetrieve(t *testing.T) {
TS := NewTestServer()
TS.Start()
defer TS.Stop()
// simulate piece stored with farmer
@ -271,7 +269,6 @@ func TestRetrieve(t *testing.T) {
func TestStore(t *testing.T) {
TS := NewTestServer()
TS.Start()
defer TS.Stop()
db := TS.s.DB.DB
@ -381,7 +378,6 @@ func TestStore(t *testing.T) {
func TestDelete(t *testing.T) {
TS := NewTestServer()
TS.Start()
defer TS.Stop()
db := TS.s.DB.DB
@ -465,8 +461,8 @@ func newTestServerStruct() *Server {
return &Server{DataDir: tempDir, DB: psDB}
}
func connect() (pb.PieceStoreRoutesClient, *grpc.ClientConn) {
conn, err := grpc.Dial("localhost:3000", grpc.WithInsecure())
func connect(addr string) (pb.PieceStoreRoutesClient, *grpc.ClientConn) {
conn, err := grpc.Dial(addr, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
@ -486,13 +482,16 @@ type TestServer struct {
func NewTestServer() *TestServer {
s := newTestServerStruct()
grpcs := grpc.NewServer()
c, conn := connect()
return &TestServer{s: s, grpcs: grpcs, conn: conn, c: c}
ts := &TestServer{s: s, grpcs: grpcs}
addr := ts.start()
ts.c, ts.conn = connect(addr)
return ts
}
func (TS *TestServer) Start() {
lis, err := net.Listen("tcp", ":3000")
func (TS *TestServer) start() (addr string) {
lis, err := net.Listen("tcp", ":0")
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
@ -503,6 +502,7 @@ func (TS *TestServer) Start() {
log.Fatalf("failed to serve: %v", err)
}
}()
return lis.Addr().String()
}
func (TS *TestServer) Stop() {