Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable travis #6

Merged
merged 1 commit into from
Oct 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
goofys
goofys.test
xout
s3proxy.jar
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
language: go
sudo: false
addons:
apt_packages:
- openjdk-7-jre-headless
install:
- go get -t ./...
- make
go:
- 1.5.1
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test: s3proxy.jar
./run-tests.sh

s3proxy.jar:
wget https://oss.sonatype.org/content/repositories/snapshots/org/gaul/s3proxy/1.5.0-SNAPSHOT/s3proxy-1.5.0-20151012.215145-8-jar-with-dependencies.jar -O s3proxy.jar

get-deps: s3proxy.jar
go get -t ./...
2 changes: 1 addition & 1 deletion goofys.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func NewGoofys(bucket string, awsConfig *aws.Config, flags *flagStorage) *Goofys
log.Println(err)
return nil
}
} else if *awsConfig.Region != "milkyway" {
} else if len(toRegion) == 0 && *awsConfig.Region != "milkyway" {
log.Printf("Unable to detect bucket region, staying at '%v'", *awsConfig.Region)
}

Expand Down
56 changes: 8 additions & 48 deletions goofys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"math/rand"
"os/exec"
"os/user"
"path/filepath"
"strconv"
"strings"
"sync"
Expand All @@ -38,10 +37,6 @@ import (
"github.com/jacobsa/fuse/fuseops"
"github.com/jacobsa/fuse/fuseutil"

"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/server"
"github.com/minio/minio/pkg/server/api"

. "gopkg.in/check.v1"
)

Expand Down Expand Up @@ -119,50 +114,20 @@ func (s *GoofysTest) waitFor(t *C, addr string) (err error) {
return
}

func (s *GoofysTest) setupMinio(t *C, addr string) (accessKey string, secretKey string) {
accessKeyID, perr := auth.GenerateAccessKeyID()
t.Assert(perr, IsNil)
secretAccessKey, perr := auth.GenerateSecretAccessKey()
t.Assert(perr, IsNil)

accessKey = string(accessKeyID)
secretKey = string(secretAccessKey)

authConf := &auth.Config{}
authConf.Users = make(map[string]*auth.User)
authConf.Users[string(accessKeyID)] = &auth.User{
Name: "testuser",
AccessKeyID: accessKey,
SecretAccessKey: secretKey,
}
auth.SetAuthConfigPath(filepath.Join(t.MkDir(), "users.json"))
perr = auth.SaveConfig(authConf)
t.Assert(perr, IsNil)

go server.Start(api.Config{ Address: addr })

err := s.waitFor(t, addr)
t.Assert(err, IsNil)

return
}

func (s *GoofysTest) SetUpSuite(t *C) {
//addr := "play.minio.io:9000"
addr := "127.0.0.1:9000"

accessKey, secretKey := s.setupMinio(t, addr)
addr := "127.0.0.1:8080"

s.awsConfig = &aws.Config{
//Credentials: credentials.AnonymousCredentials,
Credentials: credentials.NewStaticCredentials(accessKey, secretKey, ""),
Region: aws.String("milkyway"),//aws.String("us-west-2"),
Credentials: credentials.NewStaticCredentials("foo", "bar", ""),
Region: aws.String("us-west-2"),
Endpoint: aws.String(addr),
DisableSSL: aws.Bool(true),
S3ForcePathStyle: aws.Bool(true),
MaxRetries: aws.Int(0),
Logger: t,
LogLevel: aws.LogLevel(aws.LogDebug),
//Logger: t,
//LogLevel: aws.LogLevel(aws.LogDebug),
//LogLevel: aws.LogLevel(aws.LogDebug | aws.LogDebugWithHTTPBody),
}
s.s3 = s3.New(s.awsConfig)
Expand Down Expand Up @@ -210,7 +175,7 @@ func (s *GoofysTest) setupEnv(t *C, bucket string, env map[string]io.ReadSeeker)

// from https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang
func RandStringBytesMaskImprSrc(n int) string {
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
const letterBytes = "abcdefghijklmnopqrstuvwxyz0123456789"
const (
letterIdxBits = 6 // 6 bits to represent a letter index
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
Expand Down Expand Up @@ -427,7 +392,6 @@ func (s *GoofysTest) TestCreateFiles(t *C) {
}

func (s *GoofysTest) TestUnlink(t *C) {
t.Skip("minio doesn't support unlink")
fileName := "file1"

err := s.getRoot(t).Unlink(s.fs, &fileName)
Expand All @@ -436,9 +400,6 @@ func (s *GoofysTest) TestUnlink(t *C) {
// make sure that it's gone from s3
_, err = s.s3.GetObject(&s3.GetObjectInput{ Bucket: &s.fs.bucket, Key: &fileName })
t.Assert(mapAwsError(err), Equals, fuse.ENOENT)

err = s.getRoot(t).Unlink(s.fs, &fileName)
t.Assert(err, Equals, fuse.ENOENT)
}

func (s *GoofysTest) testWriteFile(t *C, fileName string, size int64, write_size int) {
Expand Down Expand Up @@ -538,7 +499,6 @@ func (s *GoofysTest) TestRmDir(t *C) {
err = root.RmDir(s.fs, &dir)
t.Assert(err, Equals, fuse.ENOTEMPTY)

t.Skip("minio doesn't support unlink")
dir = "empty_dir"
err = root.RmDir(s.fs, &dir)
t.Assert(err, IsNil)
Expand Down Expand Up @@ -566,15 +526,15 @@ func (s *GoofysTest) TestRename(t *C) {

from, to = "file1", "new_file"
err = root.Rename(s.fs, &from, root, &to)
t.Assert(err, Equals, syscall.ENOTSUP)
t.Assert(err, IsNil)

_, err = s.s3.HeadObject(&s3.HeadObjectInput{ Bucket: &s.fs.bucket, Key: &to })
t.Assert(err, IsNil)

from, to = "file3", "new_file"
dir, _ := s.LookUpInode(t, "dir1")
err = dir.Rename(s.fs, &from, root, &to)
t.Assert(err, Equals, syscall.ENOTSUP)
t.Assert(err, IsNil)

_, err = s.s3.HeadObject(&s3.HeadObjectInput{ Bucket: &s.fs.bucket, Key: &to })
t.Assert(err, IsNil)
Expand Down
20 changes: 20 additions & 0 deletions run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

set -o xtrace
set -o errexit
set -o nounset

function cleanup {
if [ "$PROXY_PID" != "" ]; then
kill $PROXY_PID
fi
}

trap cleanup EXIT

PROXY_BIN="java -jar s3proxy.jar --properties s3proxy.properties"
stdbuf -oL -eL $PROXY_BIN &
PROXY_PID=$!

go test -v ./... #-check.f TestUnlink
exit $?
6 changes: 6 additions & 0 deletions s3proxy.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
s3proxy.endpoint=http://127.0.0.1:8080
s3proxy.authorization=none
jclouds.provider=transient
jclouds.identity=local-identity
jclouds.credential=local-credential
jclouds.regions=us-west-2