diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 7a3a56e49..30695ad6c 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -3,14 +3,6 @@ include: - template: Security/License-Scanning.gitlab-ci.yml - template: Security/Dependency-Scanning.gitlab-ci.yml -.go-cache: - variables: - GOPATH: $CI_PROJECT_DIR/.go - cache: - - key: $CI_COMMIT_REF_SLUG - paths: - - .go/pkg/mod/ - variables: GOVERSION: "1.16.13" @@ -24,7 +16,6 @@ stages: golangci-lint: image: golangci/golangci-lint:v1.39.0 stage: lint - extends: .go-cache allow_failure: false rules: - if: '$CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"' @@ -71,32 +62,35 @@ run jest tests: run go tests: stage: test image: golang:$GOVERSION - extends: .go-cache rules: - if: '$CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"' script: - echo "Running featurebase unit tests..." - - go test ./... + - go test -timeout=30m ./... + tags: + - aws run go tests race: stage: test image: golang:$GOVERSION - extends: .go-cache rules: - if: '$CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"' script: - echo "Running featurebase race tests..." - - go test -race -timeout=30m ./... + - go test -race -timeout=90m ./... + tags: + - aws run go tests shardwidth22: stage: test image: golang:$GOVERSION - extends: .go-cache rules: - if: '$CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"' script: - echo "Running featurebase race tests..." - - go test -tags=shardwidth22 ./... + - go test -timeout=30m -tags=shardwidth22 ./... + tags: + - aws # we do coverage reporting from the future tests because the json # output is very difficult to human-read. The alternative would be to @@ -104,17 +98,18 @@ run go tests shardwidth22: run go tests future: stage: test image: golang:1.17.6 - extends: .go-cache rules: - if: '$CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"' script: - echo "Running featurebase unit tests..." - PKG_LIST=$(go list ./... | grep -v internal/clustertests | paste -s -d, -) - - go test -json -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ./... | tee test-report.out + - go test -timeout=30m -json -coverprofile=coverage.out -covermode=atomic -coverpkg=${PKG_LIST} ./... | tee test-report.out artifacts: paths: - coverage.out - test-report.out + tags: + - aws upload to sonarcloud: stage: test diff --git a/Makefile b/Makefile index 8545c0cb8..b98e3c803 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ .PHONY: build check-clean clean build-lattice cover cover-viz default docker docker-build docker-test docker-tag-push generate generate-protoc generate-pql generate-statik gometalinter install install-build-deps install-golangci-lint install-gometalinter install-protoc install-protoc-gen-gofast install-peg install-statik release release-build test testv testv-race testvsub testvsub-race test-txstore-rbf CLONE_URL=github.com/pilosa/pilosa -MOD_VERSION=v2 VERSION := $(shell git describe --tags 2> /dev/null || echo unknown) VARIANT = Molecula GO=go @@ -13,12 +12,14 @@ BRANCH_ID := $(BRANCH)-$(GOOS)-$(GOARCH) BUILD_TIME := $(shell date -u +%FT%T%z) SHARD_WIDTH = 20 COMMIT := $(shell git describe --exact-match >/dev/null 2>&1 || git rev-parse --short HEAD) -LDFLAGS="-X github.com/molecula/featurebase/v2.Version=$(VERSION) -X github.com/molecula/featurebase/v2.BuildTime=$(BUILD_TIME) -X github.com/molecula/featurebase/v2.Variant=$(VARIANT) -X github.com/molecula/featurebase/v2.Commit=$(COMMIT) -X github.com/molecula/featurebase/v2.TrialDeadline=$(TRIAL_DEADLINE)" +LDFLAGS="-X github.com/molecula/featurebase/v3.Version=$(VERSION) -X github.com/molecula/featurebase/v3.BuildTime=$(BUILD_TIME) -X github.com/molecula/featurebase/v3.Variant=$(VARIANT) -X github.com/molecula/featurebase/v3.Commit=$(COMMIT) -X github.com/molecula/featurebase/v3.TrialDeadline=$(TRIAL_DEADLINE)" GO_VERSION=1.16.10 DOCKER_BUILD= # set to 1 to use `docker-build` instead of `build` when creating a release BUILD_TAGS += shardwidth$(SHARD_WIDTH) TEST_TAGS = roaringparanoia UNAME := $(shell uname -s) +TEST_TIMEOUT=30m +RACE_TEST_TIMEOUT=90m ifeq ($(UNAME), Darwin) IS_MACOS:=1 else @@ -45,11 +46,11 @@ version: # Run test suite test: - $(GO) test ./... -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -v + $(GO) test ./... -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -v -timeout $(TEST_TIMEOUT) # Run test suite with race flag test-race: - CGO_ENABLED=1 $(GO) test ./... -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -race -timeout 60m -v + CGO_ENABLED=1 $(GO) test ./... -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -race -timeout $(RACE_TEST_TIMEOUT) -v testv: topt testvsub @@ -64,7 +65,7 @@ testvsub: set -e; for i in boltdb client ctl http pg pql rbf roaring server sql txkey; do \ echo; echo "___ testing subpkg $$i"; \ cd $$i; pwd; \ - $(GO) test -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -v -timeout 60m || break; \ + $(GO) test -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -v -timeout $(RACE_TEST_TIMEOUT) || break; \ echo; echo "999 done testing subpkg $$i"; \ cd ..; \ done @@ -73,7 +74,7 @@ testvsub-race: set -e; for i in boltdb client ctl http pg pql rbf roaring server sql txkey; do \ echo; echo "___ testing subpkg $$i -race"; \ cd $$i; pwd; \ - CGO_ENABLED=1 $(GO) test -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -v -race -timeout 60m || break; \ + CGO_ENABLED=1 $(GO) test -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -v -race -timeout $(RACE_TEST_TIMEOUT) || break; \ echo; echo "999 done testing subpkg $$i -race"; \ cd ..; \ done @@ -168,11 +169,11 @@ build-lattice: # `go generate` protocol buffers generate-protoc: require-protoc require-protoc-gen-gofast - $(GO) generate github.com/molecula/featurebase/v2/pb + $(GO) generate github.com/molecula/featurebase/v3/pb # `go generate` statik assets (lattice UI) generate-statik: build-lattice require-statik - $(GO) generate github.com/molecula/featurebase/v2/statik + $(GO) generate github.com/molecula/featurebase/v3/statik # `go generate` statik assets (lattice UI) in Docker generate-statik-docker: build-lattice @@ -180,7 +181,7 @@ generate-statik-docker: build-lattice # `go generate` stringers generate-stringer: - $(GO) generate github.com/molecula/featurebase/v2 + $(GO) generate github.com/molecula/featurebase/v3 generate-pql: require-peg cd pql && peg -inline pql.peg && cd .. @@ -191,7 +192,7 @@ generate-proto-grpc: require-protoc require-protoc-gen-go # TODO: Modify above commands and remove the below mv if possible. # See https://go-review.googlesource.com/c/protobuf/+/219298/ for info on --go-opt # I couldn't get it to work during development - Cody - cp -r proto/github.com/molecula/featurebase/v2/proto/ proto/ + cp -r proto/github.com/molecula/featurebase/v3/proto/ proto/ rm -rf proto/github.com # `go generate` all needed packages @@ -248,20 +249,20 @@ pilosa-fsck: # Run Pilosa tests inside Docker container docker-test: - docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) golang:$(GO_VERSION) go test -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) ./... + docker run --rm -v $(PWD):/go/src/$(CLONE_URL) -w /go/src/$(CLONE_URL) golang:$(GO_VERSION) go test -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) -timeout $(TEST_TIMEOUT) ./... # Must use bash in order to -o pipefail; otherwise the tee will hide red tests. # run top tests, not subdirs. print summary red/green after. # The \-\-\- FAIL avoids counting the extra two FAIL strings at then bottom of log.topt. topt: mv log.topt.roar log.topt.roar.prev || true - $(eval SHELL:=/bin/bash) set -o pipefail; $(GO) test -v -timeout 60m -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) 2>&1 | tee log.topt.roar + $(eval SHELL:=/bin/bash) set -o pipefail; $(GO) test -v -timeout $(RACE_TEST_TIMEOUT) -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) 2>&1 | tee log.topt.roar @echo " log.topt.roar green: \c"; cat log.topt.roar | grep PASS |wc -l @echo " log.topt.roar red: \c"; cat log.topt.roar | grep '\-\-\- FAIL' | wc -l topt-race: mv log.topt.race log.topt.race.prev || true - $(eval SHELL:=/bin/bash) set -o pipefail; CGO_ENABLED=1 $(GO) test -race -timeout 60m -v -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) 2>&1 | tee log.topt.race + $(eval SHELL:=/bin/bash) set -o pipefail; CGO_ENABLED=1 $(GO) test -race -timeout $(RACE_TEST_TIMEOUT) -v -tags='$(BUILD_TAGS) $(TEST_TAGS)' $(TESTFLAGS) 2>&1 | tee log.topt.race @echo " log.topt.race green: \c"; cat log.topt.race | grep PASS |wc -l @echo " log.topt.race red: \c"; cat log.topt.race | grep '\-\-\- FAIL' | wc -l diff --git a/api.go b/api.go index fdee2f8f7..a373b0a1b 100644 --- a/api.go +++ b/api.go @@ -21,16 +21,16 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/rbf" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/rbf" - //"github.com/molecula/featurebase/v2/pg" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/tracing" + //"github.com/molecula/featurebase/v3/pg" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/topology" + "github.com/molecula/featurebase/v3/tracing" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/api/client/grpc.go b/api/client/grpc.go index bb1479612..2bad9f413 100644 --- a/api/client/grpc.go +++ b/api/client/grpc.go @@ -6,8 +6,8 @@ import ( "crypto/tls" "sync" - "github.com/molecula/featurebase/v2/logger" - pb "github.com/molecula/featurebase/v2/proto" + "github.com/molecula/featurebase/v3/logger" + pb "github.com/molecula/featurebase/v3/proto" "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/connectivity" diff --git a/api_test.go b/api_test.go index f57bba824..0c7c63287 100644 --- a/api_test.go +++ b/api_test.go @@ -19,14 +19,14 @@ import ( "time" "github.com/golang-jwt/jwt" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/authn" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/shardwidth" - "github.com/molecula/featurebase/v2/test" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/authn" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/shardwidth" + "github.com/molecula/featurebase/v3/test" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) func TestAPI_Import(t *testing.T) { @@ -1491,6 +1491,7 @@ admin: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe"` AuthorizeURL: "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/authorize", TokenURL: "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/token", GroupEndpointURL: "https://graph.microsoft.com/v1.0/me/transitiveMemberOf/microsoft.graph.group?$count=true", + RedirectBaseURL: "https://localhost:10101", LogoutURL: "https://login.microsoftonline.com/common/oauth2/v2.0/logout", Scopes: []string{"https://graph.microsoft.com/.default", "offline_access"}, SecretKey: "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF", diff --git a/audit.go b/audit.go index c86e56b74..6ffd28eb9 100644 --- a/audit.go +++ b/audit.go @@ -2,7 +2,7 @@ package pilosa import ( - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) var NewAuditor func() testhook.Auditor = NewNopAuditor diff --git a/audit_internal_test.go b/audit_internal_test.go index 6382d9588..70cce7d2d 100644 --- a/audit_internal_test.go +++ b/audit_internal_test.go @@ -5,7 +5,7 @@ import ( "fmt" "reflect" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) // These audit hooks are desireable during testing, but not in diff --git a/audit_test.go b/audit_test.go index c887a2398..112f8bbfd 100644 --- a/audit_test.go +++ b/audit_test.go @@ -6,8 +6,8 @@ import ( "os" "reflect" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/testhook" ) // AuditLeaksOn is a global switch to turn on resource diff --git a/authn/authenticate.go b/authn/authenticate.go index 73b325055..202369a90 100644 --- a/authn/authenticate.go +++ b/authn/authenticate.go @@ -15,7 +15,7 @@ import ( "time" "github.com/golang-jwt/jwt" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" "github.com/pkg/errors" "golang.org/x/oauth2" ) @@ -117,6 +117,7 @@ type Groups struct { // Authenticate takes in a bearer token `bearer` and returns UserInfo from that token func (a *Auth) Authenticate(bearer string) (*UserInfo, error) { // parse the bearer token into a jwt.Token + // this also validates the token, and checks that it's not expired token, err := jwt.Parse(bearer, func(token *jwt.Token) (interface{}, error) { if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"]) @@ -124,39 +125,21 @@ func (a *Auth) Authenticate(bearer string) (*UserInfo, error) { return a.secretKey, nil }) if token == nil || token.Claims == nil || err != nil || !token.Valid { - return nil, errors.Wrap(err, fmt.Sprintf("%#v parsing jwt claims from access tokens", token)) + return nil, fmt.Errorf("parsing bearer token: %v", err) } userInfo := UserInfo{} - // check that token does not expire now - switch claimType := token.Claims.(type) { - case jwt.MapClaims: - if exp, ok := claimType["exp"]; ok { - var e int64 - switch expType := exp.(type) { - case float64: - e = int64(expType) - case json.Number: - e, _ = expType.Int64() - } - if e <= time.Now().Unix() { - return nil, fmt.Errorf("token expired") - } - } - userInfo.UserID = claimType["oid"].(string) - userInfo.UserName = claimType["name"].(string) - userInfo.Token = bearer + claims := token.Claims.(jwt.MapClaims) + userInfo.UserID = claims["oid"].(string) + userInfo.UserName = claims["name"].(string) + userInfo.Token = bearer - g := claimType["molecula-idp-groups"].(string) - groups, err := FromGob64(g) - if err != nil { - return nil, errors.Wrap(err, "decoding groups") - } - userInfo.Groups = groups - - default: - return nil, fmt.Errorf("could not parse jwt claims of type %T, expected jwt.MapClaims", claimType) + g := claims["molecula-idp-groups"].(string) + groups, err := FromGob64(g) + if err != nil { + return nil, errors.Wrap(err, "decoding groups") } + userInfo.Groups = groups return &userInfo, nil } @@ -194,8 +177,16 @@ func (a *Auth) Redirect(w http.ResponseWriter, r *http.Request) { return } - // with vitamin A! - enrichedTkn, err := a.addGroupMembership(token.AccessToken) + // enrich token with groups! + g, err := a.getGroups(token.AccessToken) + if err != nil { + a.logger.Warnf("getting groups from IdP: %+v", err) + http.Error(w, "Bad Request", http.StatusBadRequest) + return + } + + // with vitamin G! (for groups) + enrichedTkn, err := a.addGroupMembership(token.AccessToken, g) if err != nil { a.logger.Warnf("enriching token with group membership: %+v", err) http.Error(w, "Bad Request", http.StatusBadRequest) @@ -217,40 +208,28 @@ func (a *Auth) getToken(r *http.Request, code string) (*oauth2.Token, error) { // addGroupMembership is only called in `a.Redirect`. It adds groups to a jwt's // claims, and signs it using `a.secretKey`. -func (a *Auth) addGroupMembership(token string) (string, error) { - g, err := a.getGroups(token) - if err != nil { - return "", err - } - +func (a *Auth) addGroupMembership(token string, g []Group) (string, error) { // parse token into jwt unenriched, _, err := new(jwt.Parser).ParseUnverified(token, jwt.MapClaims{}) if unenriched == nil || unenriched.Claims == nil || err != nil { - return "", errors.Wrap(err, fmt.Sprintf("%v parsing jwt claims from access tokens", token)) + return "", fmt.Errorf("parsing bearer token: %v", err) } enriched := jwt.New(jwt.SigningMethodHS256) enriched.Claims = unenriched.Claims - var tokenStr string // parse groups into string format - switch claims := enriched.Claims.(type) { - case jwt.MapClaims: - groupString, err := ToGob64(g) - if err != nil { - return "", errors.Wrap(err, "failed to serialize groups") - } + claims := enriched.Claims.(jwt.MapClaims) + groupString, err := ToGob64(g) + if err != nil { + return "", errors.Wrap(err, "failed to serialize groups") + } + // stick it into jwt claims + claims["molecula-idp-groups"] = groupString - // stick it into jwt claims - claims["molecula-idp-groups"] = groupString - - // get stringified and signed jwt - tokenStr, err = enriched.SignedString(a.secretKey) - if err != nil { - return "", errors.Wrap(err, "signing jwt") - } - - default: - return "", fmt.Errorf("could not parse jwt claims of type %T, expected jwt.MapClaims", claims) + // get stringified and signed jwt + tokenStr, err := enriched.SignedString(a.secretKey) + if err != nil { + return "", errors.Wrap(err, "signing jwt") } return tokenStr, nil @@ -303,7 +282,7 @@ func decodeHex(hexstr string) ([]byte, error) { return nil, errors.Wrap(err, "decoding hex string to byte slice") } if len(data) != 32 { - return nil, errors.Wrap(err, "invalid key length") + return nil, fmt.Errorf("invalid key length") } return data, nil } diff --git a/authn/authenticate_internal_test.go b/authn/authenticate_internal_test.go index f937510d5..d4fd63c6c 100644 --- a/authn/authenticate_internal_test.go +++ b/authn/authenticate_internal_test.go @@ -1,16 +1,24 @@ package authn import ( + "bytes" + "encoding/hex" + "fmt" + "net/http" "net/http/httptest" "os" + "reflect" "strings" "testing" "time" - "github.com/molecula/featurebase/v2/logger" + "github.com/golang-jwt/jwt" + "github.com/molecula/featurebase/v3/logger" + "github.com/pkg/errors" ) -func TestAuth(t *testing.T) { +func NewTestAuth(t *testing.T) *Auth { + t.Helper() var ( ClientID = "e9088663-eb08-41d7-8f65-efb5f54bbb71" ClientSecret = "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF" @@ -20,7 +28,6 @@ func TestAuth(t *testing.T) { LogoutURL = "https://login.microsoftonline.com/common/oauth2/v2.0/logout" Scopes = []string{"https://graph.microsoft.com/.default", "offline_access"} Key = "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF" - ShortKey = "DEADBEEFD" ) a, err := NewAuth( @@ -36,9 +43,13 @@ func TestAuth(t *testing.T) { Key, ) if err != nil { - t.Errorf("building auth object%s", err) + t.Fatalf("building auth object%s", err) } + return a +} +func TestAuth(t *testing.T) { + a := NewTestAuth(t) t.Run("SetCookie", func(t *testing.T) { w := httptest.NewRecorder() err := a.setCookie(w, "a cookie value", time.Now().Add(time.Hour)) @@ -53,23 +64,267 @@ func TestAuth(t *testing.T) { if got, want := w.Result().Cookies()[0].Path, "/"; got != want { t.Fatalf("path=%s, want %s", got, want) } - }) t.Run("KeyLength", func(t *testing.T) { _, err := NewAuth( logger.NewStandardLogger(os.Stdout), "http://localhost:10101/", - Scopes, - AuthorizeURL, - TokenURL, - GroupEndpointURL, - LogoutURL, - ClientID, - ClientSecret, - ShortKey, + []string{"https://graph.microsoft.com/.default", "offline_access"}, + "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/authorize", + "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/token", + "https://graph.microsoft.com/v1.0/me/transitiveMemberOf/microsoft.graph.group?$count=true", + "https://login.microsoftonline.com/common/oauth2/v2.0/logout", + "e9088663-eb08-41d7-8f65-efb5f54bbb71", + "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF", + "DEADBEEFD", ) if err == nil || !strings.Contains(err.Error(), "decoding secret key") { t.Fatalf("expected error decoding secret key got: %v", err) } }) + t.Run("GetSecretKey", func(t *testing.T) { + want, _ := hex.DecodeString("DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF") + if got := a.SecretKey(); !bytes.Equal(got, want) { + t.Fatalf("expected %v, got %v", got, want) + } + }) + cases := []struct { + name string + uid string + uname string + exp interface{} + groups []Group + err error + }{ + { + name: "GoodToken", + uid: "42", + uname: "A. Token", + groups: []Group{ + { + GroupID: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe", + GroupName: "adminGroup", + }, + }, + }, + { + name: "ExpiredToken", + uid: "42", + uname: "A. Token", + groups: []Group{ + { + GroupID: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe", + GroupName: "adminGroup", + }, + }, + exp: "-17764800", + err: errors.Wrap(fmt.Errorf("Token is expired"), "parsing bearer token"), + }, + } + for _, test := range cases { + t.Run(test.name, func(t *testing.T) { + tkn := jwt.New(jwt.SigningMethodHS256) + claims := tkn.Claims.(jwt.MapClaims) + groupString, err := ToGob64(test.groups) + if err != nil { + t.Fatalf("unexpected error when gobbing groups %v", err) + } + claims["molecula-idp-groups"] = groupString + claims["oid"] = test.uid + claims["name"] = test.uname + if test.exp != nil { + claims["exp"] = test.exp + } + token, err := tkn.SignedString(a.SecretKey()) + if err != nil { + t.Fatalf("unexpected error when signing token %v", err) + } + + uinfo, err := a.Authenticate(token) + // okay this part kind of sucks bc we need to check errors and i + // dont want to write a whole new test for things that should have + // errors just to avoid this mess. errors.Is doesn't work either + if (test.err == nil && err != nil) || (test.err != nil && err == nil) { + t.Fatalf("expected %v, but got %v", test.err, err) + } else if test.err != nil && err != nil { + if test.err.Error() != err.Error() { + t.Fatalf("expected %v, but got %v", test.err, err) + } else { + return + } + } + + if !reflect.DeepEqual(uinfo.Groups, test.groups) { + t.Fatalf("expected %v, got %v", test.groups, uinfo.Groups) + } + if !reflect.DeepEqual(uinfo.UserID, test.uid) { + t.Fatalf("expected %v, got %v", test.uid, uinfo.UserID) + } + if !reflect.DeepEqual(uinfo.UserName, test.uname) { + t.Fatalf("expected %v, got %v", test.uname, uinfo.UserName) + } + }) + } +} + +func TestGobs(t *testing.T) { + t.Run("goodGob!", func(t *testing.T) { + g := []Group{ + { + GroupID: "groupA", + GroupName: "groupA-Name", + }, + { + GroupID: "groupB", + GroupName: "groupB-Name", + }, + { + GroupID: "groupC", + GroupName: "groupC-Name", + }, + } + gobbed, err := ToGob64(g) + if err != nil { + t.Fatalf("could not gob %+v", g) + } + ungobbed, err := FromGob64(gobbed) + if err != nil { + t.Fatalf("could not ungob %+v", gobbed) + } + if !reflect.DeepEqual(ungobbed, g) { + t.Fatalf("expected %v, got %v", g, ungobbed) + } + }) +} + +func TestDecodeHex(t *testing.T) { + t.Run("cantDecode", func(t *testing.T) { + _, err := decodeHex("gggg") + if err == nil { + t.Fatalf("expected err cannot decode slice, got nil") + } + }) + t.Run("tooSmall", func(t *testing.T) { + _, err := decodeHex("DEADBEEF") + if err == nil { + t.Fatalf("expected err wrong length, got nil") + } + }) + t.Run("tooBig", func(t *testing.T) { + _, err := decodeHex("DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF") + if err == nil { + t.Fatalf("expected err wrong length, got nil") + } + }) + t.Run("justRight", func(t *testing.T) { + _, err := decodeHex("DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF") + if err != nil { + t.Fatalf("expected nil, got %v", err) + } + }) +} + +func TestAddGroupMembership(t *testing.T) { + cases := []struct { + name string + groups []Group + err error + }{ + { + name: "emptyGroups", + groups: []Group{}, + err: nil, + }, + { + name: "happyPath", + groups: []Group{ + { + GroupID: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe", + GroupName: "adminGroup", + }, + }, + err: nil, + }, + } + a := NewTestAuth(t) + for _, test := range cases { + t.Run(test.name, func(t *testing.T) { + tkn := jwt.New(jwt.SigningMethodHS256) + token, err := tkn.SignedString(a.SecretKey()) + if err != nil { + t.Fatalf("unexpected error when signing token %v", err) + } + + tokenWithGroups, err := a.addGroupMembership(token, test.groups) + // okay this part kind of sucks bc we need to check errors and i + // dont want to write a whole new test for things that should have + // errors just to avoid this mess. errors.Is doesn't work either + if (test.err == nil && err != nil) || (test.err != nil && err == nil) { + t.Fatalf("expected %v but got %v", test.err, err) + } else if test.err != nil && err != nil { + if test.err.Error() != err.Error() { + t.Fatalf("expected %v, but got %v", test.err, err) + } else { + return + } + } + parsed, _, err := new(jwt.Parser).ParseUnverified(tokenWithGroups, jwt.MapClaims{}) + if err != nil { + t.Fatalf("unexpected error parsing token %v", err) + } + + claims := parsed.Claims.(jwt.MapClaims) + groups, err := FromGob64(claims["molecula-idp-groups"].(string)) + if err != nil { + t.Fatalf("unexpected error parsing groupString %v", err) + } + + if !reflect.DeepEqual(groups, test.groups) { + t.Fatalf("expected %v, got %v", test.groups, groups) + } + }) + } +} + +func TestHandlers(t *testing.T) { + a := NewTestAuth(t) + t.Run("login", func(t *testing.T) { + req := httptest.NewRequest("GET", "/login", nil) + w := httptest.NewRecorder() + a.Login(w, req) + resp := w.Result() + if resp.StatusCode != http.StatusTemporaryRedirect { + t.Fatalf("expected redirect, got %v", resp.StatusCode) + } + redirect := a.oAuthConfig.AuthCodeURL(a.oAuthConfig.Endpoint.AuthURL) + if got, err := resp.Location(); err != nil || got.String() != redirect { + t.Fatalf("expected %v, got %v", redirect, got.Path) + } + }) + t.Run("logout", func(t *testing.T) { + req := httptest.NewRequest("GET", "/logout", nil) + w := httptest.NewRecorder() + a.Logout(w, req) + resp := w.Result() + if resp.StatusCode != http.StatusTemporaryRedirect { + t.Fatalf("expected redirect, got %v", resp.StatusCode) + } + redirect := fmt.Sprintf("%s?post_logout_redirect_uri=%s/", a.logoutEndpoint, a.fbURL) + if got, err := resp.Location(); err != nil || got.String() != redirect { + t.Fatalf("expected %v, got %v", redirect, got.Path) + } + for _, c := range resp.Cookies() { + if c.Name == "molecula-chip" { + if c.Value != "" { + t.Fatalf("cookie not set to empty value!") + } + want := time.Unix(0, 0).Unix() + got := c.Expires.Unix() + if want != got { + t.Fatalf("expected %v, got %v", want, got) + } + break + } + } + }) } diff --git a/authz/authorization.go b/authz/authorization.go index a2127f33d..bd57ff521 100644 --- a/authz/authorization.go +++ b/authz/authorization.go @@ -19,7 +19,7 @@ import ( "io" "io/ioutil" - "github.com/molecula/featurebase/v2/authn" + "github.com/molecula/featurebase/v3/authn" "gopkg.in/yaml.v2" ) @@ -120,7 +120,7 @@ func (p *GroupPermissions) IsAdmin(groups []authn.Group) bool { func (p *GroupPermissions) GetAuthorizedIndexList(groups []authn.Group, desiredPermission Permission) (indexList []string) { // if user is admin, find all indexes in permissions file and return them - if admin := p.IsAdmin(groups); admin { + if p.IsAdmin(groups) { for groupId := range p.Permissions { for index := range p.Permissions[groupId] { indexList = append(indexList, index) @@ -132,7 +132,7 @@ func (p *GroupPermissions) GetAuthorizedIndexList(groups []authn.Group, desiredP for _, group := range groups { if _, ok := p.Permissions[group.GroupID]; ok { for index, permission := range p.Permissions[group.GroupID] { - if permission >= desiredPermission { + if permission.Satisfies(desiredPermission) { indexList = append(indexList, index) } } diff --git a/authz/authorization_test.go b/authz/authorization_test.go index 0b0f9dbbe..5bc0602dc 100644 --- a/authz/authorization_test.go +++ b/authz/authorization_test.go @@ -20,8 +20,8 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/authn" - "github.com/molecula/featurebase/v2/authz" + "github.com/molecula/featurebase/v3/authn" + "github.com/molecula/featurebase/v3/authz" ) func TestAuth_ReadPermissionsFile(t *testing.T) { diff --git a/boltdb/translate.go b/boltdb/translate.go index 939be909c..8ff56f7e4 100644 --- a/boltdb/translate.go +++ b/boltdb/translate.go @@ -12,7 +12,7 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" "github.com/pkg/errors" bolt "go.etcd.io/bbolt" diff --git a/boltdb/translate_test.go b/boltdb/translate_test.go index c1640d62e..201971644 100644 --- a/boltdb/translate_test.go +++ b/boltdb/translate_test.go @@ -10,10 +10,10 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/topology" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/topology" ) //var vv = pilosa.VV diff --git a/broadcast.go b/broadcast.go index 022508855..663044497 100644 --- a/broadcast.go +++ b/broadcast.go @@ -4,7 +4,7 @@ package pilosa import ( "fmt" - "github.com/molecula/featurebase/v2/topology" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" ) diff --git a/bsi.go b/bsi.go index 7e776d64b..719404897 100644 --- a/bsi.go +++ b/bsi.go @@ -4,7 +4,7 @@ package pilosa import ( "math/bits" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/roaring" ) // bsiData contains BSI-structured data. diff --git a/cache.go b/cache.go index 11a9e58ac..4dd5d5e4c 100644 --- a/cache.go +++ b/cache.go @@ -10,9 +10,9 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/lru" - pb "github.com/molecula/featurebase/v2/proto" - "github.com/molecula/featurebase/v2/stats" + "github.com/molecula/featurebase/v3/lru" + pb "github.com/molecula/featurebase/v3/proto" + "github.com/molecula/featurebase/v3/stats" "github.com/pkg/errors" ) diff --git a/cache_test.go b/cache_test.go index d3691e5b4..1ff8d0fff 100644 --- a/cache_test.go +++ b/cache_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" ) // Ensure cache stays constrained to its configured size. diff --git a/catcher.go b/catcher.go index e1c5fd4d9..a1f128d65 100644 --- a/catcher.go +++ b/catcher.go @@ -2,9 +2,9 @@ package pilosa import ( - "github.com/molecula/featurebase/v2/roaring" - txkey "github.com/molecula/featurebase/v2/short_txkey" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/roaring" + txkey "github.com/molecula/featurebase/v3/short_txkey" + "github.com/molecula/featurebase/v3/vprint" ) // catcher is useful to report error locations with a diff --git a/client.go b/client.go index 75741fcd3..35e3230de 100644 --- a/client.go +++ b/client.go @@ -6,9 +6,9 @@ import ( "io" "time" - "github.com/molecula/featurebase/v2/ingest" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/topology" + "github.com/molecula/featurebase/v3/ingest" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/topology" ) // Bit represents the intersection of a row and a column. It can be specified by @@ -36,7 +36,7 @@ type FieldValue struct { // While I understand that putting the entire Client behind an interface might require this many methods, // I don't want to let it go unquestioned. // Another note from Travis: I think we eventually want to unify `InternalClient` with -// the `github.com/molecula/featurebase/v2/client` client. +// the `github.com/molecula/featurebase/v3/client` client. // Doing that may obviate the need to refactor this. type InternalClient interface { InternalQueryClient diff --git a/client/batch.go b/client/batch.go index 182d4e476..87a8952ee 100644 --- a/client/batch.go +++ b/client/batch.go @@ -6,9 +6,9 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/client/egpool" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/client/egpool" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/roaring" "github.com/pkg/errors" ) diff --git a/client/batch_test.go b/client/batch_test.go index cc8ab891f..8823a5099 100644 --- a/client/batch_test.go +++ b/client/batch_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3/test" "github.com/pkg/errors" ) diff --git a/client/client.go b/client/client.go index 082a56634..bc5740514 100644 --- a/client/client.go +++ b/client/client.go @@ -20,13 +20,13 @@ import ( "time" "github.com/golang/protobuf/proto" //nolint:staticcheck - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/logger" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/pb" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/stats" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/logger" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/pb" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/stats" "github.com/opentracing/opentracing-go" "github.com/pkg/errors" "golang.org/x/sync/errgroup" diff --git a/client/client_it_test.go b/client/client_it_test.go index ef79f105c..ff8614d78 100644 --- a/client/client_it_test.go +++ b/client/client_it_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/disco" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/shardwidth" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3/disco" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/shardwidth" + "github.com/molecula/featurebase/v3/test" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" ) diff --git a/client/client_test.go b/client/client_test.go index ea073eaac..170cf5093 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -10,7 +10,7 @@ import ( "reflect" "testing" - pnet "github.com/molecula/featurebase/v2/net" + pnet "github.com/molecula/featurebase/v3/net" ) func TestQueryWithError(t *testing.T) { diff --git a/client/cluster.go b/client/cluster.go index dfc407ddb..0f1230583 100644 --- a/client/cluster.go +++ b/client/cluster.go @@ -7,7 +7,7 @@ package client import ( "sync" - pnet "github.com/molecula/featurebase/v2/net" + pnet "github.com/molecula/featurebase/v3/net" ) // Cluster contains hosts in a Pilosa cluster. diff --git a/client/cluster_test.go b/client/cluster_test.go index 797427371..36790b7f8 100644 --- a/client/cluster_test.go +++ b/client/cluster_test.go @@ -7,7 +7,7 @@ package client import ( "testing" - pnet "github.com/molecula/featurebase/v2/net" + pnet "github.com/molecula/featurebase/v3/net" ) func TestNewClusterWithHost(t *testing.T) { diff --git a/client/csv/csv.go b/client/csv/csv.go index e2dd8f6a2..a0797c52d 100644 --- a/client/csv/csv.go +++ b/client/csv/csv.go @@ -10,7 +10,7 @@ import ( "strings" "time" - "github.com/molecula/featurebase/v2/client" + "github.com/molecula/featurebase/v3/client" ) // Format is the format of the data in the CSV file. diff --git a/client/csv/csv_it_test.go b/client/csv/csv_it_test.go index de901816c..c530b3147 100644 --- a/client/csv/csv_it_test.go +++ b/client/csv/csv_it_test.go @@ -10,8 +10,8 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/client" - "github.com/molecula/featurebase/v2/client/csv" + "github.com/molecula/featurebase/v3/client" + "github.com/molecula/featurebase/v3/client/csv" ) func TestCSVIterate(t *testing.T) { diff --git a/client/csv/csv_test.go b/client/csv/csv_test.go index 870237fb3..3be57f12d 100644 --- a/client/csv/csv_test.go +++ b/client/csv/csv_test.go @@ -8,9 +8,9 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/client" - "github.com/molecula/featurebase/v2/client/csv" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/client" + "github.com/molecula/featurebase/v3/client/csv" ) func TestCSVColumnIterator(t *testing.T) { diff --git a/client/doc.go b/client/doc.go index afd6cc244..5c519c819 100644 --- a/client/doc.go +++ b/client/doc.go @@ -11,7 +11,7 @@ Usage: import ( "fmt" - "github.com/molecula/featurebase/v2/client" + "github.com/molecula/featurebase/v3/client" ) // Create a Client instance diff --git a/client/egpool/egpool_test.go b/client/egpool/egpool_test.go index 4413b813b..af5132e50 100644 --- a/client/egpool/egpool_test.go +++ b/client/egpool/egpool_test.go @@ -5,7 +5,7 @@ import ( "errors" "testing" - "github.com/molecula/featurebase/v2/client/egpool" + "github.com/molecula/featurebase/v3/client/egpool" ) func TestEGPool(t *testing.T) { diff --git a/client/ingest_api_batch.go b/client/ingest_api_batch.go index 2f6d35d5e..a1ae7a1c5 100644 --- a/client/ingest_api_batch.go +++ b/client/ingest_api_batch.go @@ -3,7 +3,7 @@ package client import ( "time" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" "github.com/pkg/errors" ) diff --git a/client/ingest_api_batch_test.go b/client/ingest_api_batch_test.go index ff5692b1b..9abfa15c6 100644 --- a/client/ingest_api_batch_test.go +++ b/client/ingest_api_batch_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/test" ) func TestIngestAPIBatchAdd(t *testing.T) { diff --git a/client/orm.go b/client/orm.go index 0c4262d63..ddb77bbd4 100644 --- a/client/orm.go +++ b/client/orm.go @@ -13,7 +13,7 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/pql" + "github.com/molecula/featurebase/v3/pql" "github.com/pkg/errors" ) diff --git a/client/orm_test.go b/client/orm_test.go index 595710e53..650d113c3 100644 --- a/client/orm_test.go +++ b/client/orm_test.go @@ -13,8 +13,8 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pql" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pql" "github.com/pkg/errors" ) diff --git a/client/record_test.go b/client/record_test.go index b2aa892c8..7cb23b216 100644 --- a/client/record_test.go +++ b/client/record_test.go @@ -7,7 +7,7 @@ package client_test import ( "testing" - "github.com/molecula/featurebase/v2/client" + "github.com/molecula/featurebase/v3/client" ) func TestColumnShard(t *testing.T) { diff --git a/client/response.go b/client/response.go index b7ad51a84..8aa3c8c1a 100644 --- a/client/response.go +++ b/client/response.go @@ -8,7 +8,7 @@ import ( "encoding/json" "fmt" - "github.com/molecula/featurebase/v2/pb" + "github.com/molecula/featurebase/v3/pb" ) // QueryResponse types. diff --git a/client/response_test.go b/client/response_test.go index 41bd0b916..7cce0de22 100644 --- a/client/response_test.go +++ b/client/response_test.go @@ -11,7 +11,7 @@ import ( "reflect" "testing" - "github.com/molecula/featurebase/v2/pb" + "github.com/molecula/featurebase/v3/pb" ) func TestNewRowResultFromInternal(t *testing.T) { diff --git a/client/shardnodes.go b/client/shardnodes.go index 332cb818c..52161be35 100644 --- a/client/shardnodes.go +++ b/client/shardnodes.go @@ -7,7 +7,7 @@ package client import ( "sync" - pnet "github.com/molecula/featurebase/v2/net" + pnet "github.com/molecula/featurebase/v3/net" ) type shardNodes struct { diff --git a/cluster.go b/cluster.go index 6ae257352..1f45d2c15 100644 --- a/cluster.go +++ b/cluster.go @@ -10,12 +10,12 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/tracing" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/topology" + "github.com/molecula/featurebase/v3/tracing" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/cluster_internal_test.go b/cluster_internal_test.go index fa3afd983..e2261a41f 100644 --- a/cluster_internal_test.go +++ b/cluster_internal_test.go @@ -12,11 +12,11 @@ import ( "time" "github.com/davecgh/go-spew/spew" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/topology" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/topology" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) // Ensure that fragCombos creates the correct fragment mapping. diff --git a/cmd.go b/cmd.go index 05036b941..73f54d17f 100644 --- a/cmd.go +++ b/cmd.go @@ -4,7 +4,7 @@ package pilosa import ( "io" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" ) // CmdIO holds standard unix inputs and outputs. diff --git a/cmd/backup.go b/cmd/backup.go index 28712123d..0a0d5dd28 100644 --- a/cmd/backup.go +++ b/cmd/backup.go @@ -5,7 +5,7 @@ import ( "context" "io" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" "github.com/spf13/cobra" ) diff --git a/cmd/badloader/badloader.go b/cmd/badloader/badloader.go index f95d0a649..642137575 100644 --- a/cmd/badloader/badloader.go +++ b/cmd/badloader/badloader.go @@ -12,10 +12,10 @@ import ( "io/ioutil" gohttp "net/http" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/http" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/vprint" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/http" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/vprint" "os" "strconv" diff --git a/cmd/check.go b/cmd/check.go index ac1700e07..f22dcd3a0 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" ) var checker *ctl.CheckCommand diff --git a/cmd/chksum.go b/cmd/chksum.go index a9fa14b0c..54a8643f9 100644 --- a/cmd/chksum.go +++ b/cmd/chksum.go @@ -5,7 +5,7 @@ import ( "context" "io" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" "github.com/spf13/cobra" ) diff --git a/cmd/config.go b/cmd/config.go index 19d6bad7e..fc3e11b24 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -7,8 +7,8 @@ import ( "github.com/spf13/cobra" - "github.com/molecula/featurebase/v2/ctl" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3/ctl" + "github.com/molecula/featurebase/v3/server" ) var conf *ctl.ConfigCommand diff --git a/cmd/convert.go b/cmd/convert.go index 4b86eff60..2a9f5711a 100644 --- a/cmd/convert.go +++ b/cmd/convert.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/cobra" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" ) var inspector *ctl.InspectCommand diff --git a/cmd/export.go b/cmd/export.go index 8d97b742f..aae8f13d9 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" ) var Exporter *ctl.ExportCommand diff --git a/cmd/export_test.go b/cmd/export_test.go index 1ff43a2ab..4a97ece8c 100644 --- a/cmd/export_test.go +++ b/cmd/export_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/cmd" + "github.com/molecula/featurebase/v3/cmd" ) func TestExportHelp(t *testing.T) { diff --git a/cmd/featurebase-parse-sql/main.go b/cmd/featurebase-parse-sql/main.go index d3143e419..10dcfc3cd 100644 --- a/cmd/featurebase-parse-sql/main.go +++ b/cmd/featurebase-parse-sql/main.go @@ -9,7 +9,7 @@ import ( "os" "strings" - "github.com/molecula/featurebase/v2/sql2" + "github.com/molecula/featurebase/v3/sql2" ) func main() { diff --git a/cmd/featurebase/main.go b/cmd/featurebase/main.go index f185eac29..42f814fe0 100644 --- a/cmd/featurebase/main.go +++ b/cmd/featurebase/main.go @@ -8,7 +8,7 @@ import ( "fmt" "os" - "github.com/molecula/featurebase/v2/cmd" + "github.com/molecula/featurebase/v3/cmd" ) func main() { diff --git a/cmd/generate_config.go b/cmd/generate_config.go index 2ee184ab9..ce671f886 100644 --- a/cmd/generate_config.go +++ b/cmd/generate_config.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" ) var generateConf *ctl.GenerateConfigCommand diff --git a/cmd/import.go b/cmd/import.go index 0ad7e293c..243f440e8 100644 --- a/cmd/import.go +++ b/cmd/import.go @@ -5,8 +5,8 @@ import ( "context" "io" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/ctl" "github.com/spf13/cobra" ) diff --git a/cmd/import_test.go b/cmd/import_test.go index d3713b67a..bc640dc82 100644 --- a/cmd/import_test.go +++ b/cmd/import_test.go @@ -5,10 +5,10 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" - "github.com/molecula/featurebase/v2/cmd" - "github.com/molecula/featurebase/v2/pql" + "github.com/molecula/featurebase/v3/cmd" + "github.com/molecula/featurebase/v3/pql" ) func TestImportHelp(t *testing.T) { diff --git a/cmd/keygen.go b/cmd/keygen.go index 9a4faa940..8bf9166f0 100644 --- a/cmd/keygen.go +++ b/cmd/keygen.go @@ -5,7 +5,7 @@ import ( "context" "io" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" "github.com/spf13/cobra" ) @@ -13,9 +13,9 @@ func newKeygenCommand(stdin io.Reader, stdout io.Writer, stderr io.Writer) *cobr cmd := ctl.NewKeygenCommand(stdin, stdout, stderr) ccmd := &cobra.Command{ Use: "keygen", - Short: "Generate keys for authentication.", + Short: "Generate secret key for authentication.", Long: ` -Generate hash and block keys to configure FeatureBase for Authentication. +Generate secret key to configure FeatureBase for Authentication. `, RunE: func(c *cobra.Command, args []string) error { return cmd.Run(context.Background()) @@ -23,6 +23,6 @@ Generate hash and block keys to configure FeatureBase for Authentication. } flags := ccmd.Flags() - flags.IntVarP(&cmd.KeyLength, "length", "l", 32, "length of keys to produce") + flags.IntVarP(&cmd.KeyLength, "length", "l", 32, "length of the key to produce") return ccmd } diff --git a/cmd/pilosa-bench/main.go b/cmd/pilosa-bench/main.go index 8f1569028..15c7f4e6b 100644 --- a/cmd/pilosa-bench/main.go +++ b/cmd/pilosa-bench/main.go @@ -16,8 +16,8 @@ import ( "strings" "time" - "github.com/molecula/featurebase/v2" - phttp "github.com/molecula/featurebase/v2/http" + "github.com/molecula/featurebase/v3" + phttp "github.com/molecula/featurebase/v3/http" "golang.org/x/sync/errgroup" ) diff --git a/cmd/random-query/main.go b/cmd/random-query/main.go index ed4416a28..282e9034b 100644 --- a/cmd/random-query/main.go +++ b/cmd/random-query/main.go @@ -16,12 +16,12 @@ import ( "time" "github.com/gogo/protobuf/proto" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/client" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/pb" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/vprint" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/client" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/pb" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/vprint" "github.com/pkg/errors" vegeta "github.com/tsenart/vegeta/v12/lib" ) diff --git a/cmd/random-query/main_test.go b/cmd/random-query/main_test.go index 6f17c6518..2c847217f 100644 --- a/cmd/random-query/main_test.go +++ b/cmd/random-query/main_test.go @@ -7,12 +7,12 @@ import ( "strconv" "testing" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) func Test_RandomQuery(t *testing.T) { diff --git a/cmd/rbf.go b/cmd/rbf.go index 15c9900fd..b7c1925c4 100644 --- a/cmd/rbf.go +++ b/cmd/rbf.go @@ -8,7 +8,7 @@ import ( "io" "strconv" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" "github.com/spf13/cobra" ) diff --git a/cmd/restore.go b/cmd/restore.go index bc9271d0e..071463714 100644 --- a/cmd/restore.go +++ b/cmd/restore.go @@ -5,7 +5,7 @@ import ( "context" "io" - "github.com/molecula/featurebase/v2/ctl" + "github.com/molecula/featurebase/v3/ctl" "github.com/spf13/cobra" ) diff --git a/cmd/roaring-migrate/main.go b/cmd/roaring-migrate/main.go index 4ca91bec0..72e6fa94a 100644 --- a/cmd/roaring-migrate/main.go +++ b/cmd/roaring-migrate/main.go @@ -12,11 +12,11 @@ import ( "strings" "syscall" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/rbf" - "github.com/molecula/featurebase/v2/rbf/cfg" - "github.com/molecula/featurebase/v2/roaring" - txkey "github.com/molecula/featurebase/v2/short_txkey" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/rbf" + "github.com/molecula/featurebase/v3/rbf/cfg" + "github.com/molecula/featurebase/v3/roaring" + txkey "github.com/molecula/featurebase/v3/short_txkey" "github.com/spf13/cobra" ) diff --git a/cmd/root.go b/cmd/root.go index c164bed97..f32cc5875 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -6,7 +6,7 @@ import ( "io" "strings" - pilosa "github.com/molecula/featurebase/v2" + pilosa "github.com/molecula/featurebase/v3" "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" diff --git a/cmd/root_test.go b/cmd/root_test.go index 23a36cd8c..00f2072d8 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -12,8 +12,8 @@ import ( "time" - "github.com/molecula/featurebase/v2/cmd" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/cmd" + "github.com/molecula/featurebase/v3/testhook" "github.com/spf13/cobra" ) diff --git a/cmd/server.go b/cmd/server.go index 60a541a0f..e03266d5b 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -4,10 +4,10 @@ package cmd import ( "io" - "github.com/molecula/featurebase/v2/ctl" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/tracing" - "github.com/molecula/featurebase/v2/tracing/opentracing" + "github.com/molecula/featurebase/v3/ctl" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/tracing" + "github.com/molecula/featurebase/v3/tracing/opentracing" "github.com/pkg/errors" "github.com/spf13/cobra" jaegercfg "github.com/uber/jaeger-client-go/config" diff --git a/cmd/server_test.go b/cmd/server_test.go index 0843822b1..f2d3cf057 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/cmd" - _ "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/toml" + "github.com/molecula/featurebase/v3/cmd" + _ "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/toml" "github.com/pkg/errors" ) diff --git a/cmd/slurp/slurp.go b/cmd/slurp/slurp.go index 800a5a773..8b4eaef85 100644 --- a/cmd/slurp/slurp.go +++ b/cmd/slurp/slurp.go @@ -17,10 +17,10 @@ import ( "strings" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/http" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/vprint" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/http" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/vprint" ) // slurp: slurp is a load-tester for importing bulk data. diff --git a/ctl/backup.go b/ctl/backup.go index 302041dfe..8d3aa4e1a 100644 --- a/ctl/backup.go +++ b/ctl/backup.go @@ -12,10 +12,10 @@ import ( "path/filepath" "time" - pilosa "github.com/molecula/featurebase/v2" - fb_http "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/topology" + pilosa "github.com/molecula/featurebase/v3" + fb_http "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) @@ -60,7 +60,7 @@ func NewBackupCommand(stdin io.Reader, stdout, stderr io.Writer) *BackupCommand CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr), Concurrency: 1, RetryPeriod: time.Minute, - Pprof: "localhost:43809", + Pprof: "localhost:0", } } diff --git a/ctl/check.go b/ctl/check.go index da3a3412a..655394757 100644 --- a/ctl/check.go +++ b/ctl/check.go @@ -9,8 +9,8 @@ import ( "path/filepath" "syscall" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/roaring" "github.com/pkg/errors" ) diff --git a/ctl/check_test.go b/ctl/check_test.go index cad35a4c3..229fcff44 100644 --- a/ctl/check_test.go +++ b/ctl/check_test.go @@ -10,7 +10,7 @@ import ( "context" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) func TestCheckCommand_RunCacheFile(t *testing.T) { diff --git a/ctl/chksum.go b/ctl/chksum.go index af2430efb..5b10d56c9 100644 --- a/ctl/chksum.go +++ b/ctl/chksum.go @@ -8,8 +8,8 @@ import ( "io" "github.com/cespare/xxhash" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/server" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/server" ) // ChkSumCommand represents a command for backing up a Pilosa node. diff --git a/ctl/common.go b/ctl/common.go index 558cdece3..028a1250a 100644 --- a/ctl/common.go +++ b/ctl/common.go @@ -7,9 +7,9 @@ import ( gohttp "net/http" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/server" "github.com/pkg/errors" "github.com/spf13/pflag" ) diff --git a/ctl/config.go b/ctl/config.go index 526997cc0..cd4331e18 100644 --- a/ctl/config.go +++ b/ctl/config.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/server" toml "github.com/pelletier/go-toml" ) diff --git a/ctl/config_test.go b/ctl/config_test.go index a251ae008..9594229ad 100644 --- a/ctl/config_test.go +++ b/ctl/config_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3/server" ) func TestConfigCommand_Run(t *testing.T) { diff --git a/ctl/export.go b/ctl/export.go index 8df67c79e..43c988693 100644 --- a/ctl/export.go +++ b/ctl/export.go @@ -6,8 +6,8 @@ import ( "io" "os" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/server" "github.com/pkg/errors" ) diff --git a/ctl/export_test.go b/ctl/export_test.go index 144ad3417..8dbdf08c3 100644 --- a/ctl/export_test.go +++ b/ctl/export_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/test" ) func TestExportCommand_Validation(t *testing.T) { diff --git a/ctl/generate_config.go b/ctl/generate_config.go index 96ae06f56..634b69ff9 100644 --- a/ctl/generate_config.go +++ b/ctl/generate_config.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/server" "github.com/pelletier/go-toml" "github.com/pkg/errors" ) diff --git a/ctl/import.go b/ctl/import.go index f6ecf148c..34689ec9c 100644 --- a/ctl/import.go +++ b/ctl/import.go @@ -11,9 +11,9 @@ import ( "strconv" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/server" "github.com/pkg/errors" ) diff --git a/ctl/import_test.go b/ctl/import_test.go index fd3a2d66b..b9327bb9b 100644 --- a/ctl/import_test.go +++ b/ctl/import_test.go @@ -14,9 +14,9 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/testhook" ) func TestImportCommand_Validation(t *testing.T) { diff --git a/ctl/inspect.go b/ctl/inspect.go index 0848c9cbf..73d197501 100644 --- a/ctl/inspect.go +++ b/ctl/inspect.go @@ -19,9 +19,9 @@ import ( "unsafe" "github.com/gogo/protobuf/proto" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pb" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pb" + "github.com/molecula/featurebase/v3/roaring" "github.com/pkg/errors" ) diff --git a/ctl/inspect_test.go b/ctl/inspect_test.go index 94ed12937..3528edbe7 100644 --- a/ctl/inspect_test.go +++ b/ctl/inspect_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) func TestInspectCommand_Run(t *testing.T) { diff --git a/ctl/keygen.go b/ctl/keygen.go index 06cc797ad..19b4f8026 100644 --- a/ctl/keygen.go +++ b/ctl/keygen.go @@ -7,10 +7,10 @@ import ( "io" "github.com/gorilla/securecookie" - pilosa "github.com/molecula/featurebase/v2" + pilosa "github.com/molecula/featurebase/v3" ) -// Keygen represents a command for generating crytographic keys. +// Keygen represents a command for generating a cryptographic key. type KeygenCommand struct { CmdIO *pilosa.CmdIO KeyLength int @@ -23,9 +23,8 @@ func NewKeygenCommand(stdin io.Reader, stdout, stderr io.Writer) *KeygenCommand } } -// Run keys to use for authentication . +// Run keygen to obtain key to use for authentication . func (kg *KeygenCommand) Run(_ context.Context) error { - fmt.Printf("hash-key = \"%+x\"\n", securecookie.GenerateRandomKey(kg.KeyLength)) - fmt.Printf("block-key = \"%+x\"\n", securecookie.GenerateRandomKey(kg.KeyLength)) + fmt.Printf("secret-key = \"%+x\"\n", securecookie.GenerateRandomKey(kg.KeyLength)) return nil } diff --git a/ctl/main_test.go b/ctl/main_test.go index e4c50bb9b..cbd81d2ff 100644 --- a/ctl/main_test.go +++ b/ctl/main_test.go @@ -9,7 +9,7 @@ import ( _ "net/http/pprof" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) func TestMain(m *testing.M) { diff --git a/ctl/rbf_check.go b/ctl/rbf_check.go index f3d40912d..cc6ec3465 100644 --- a/ctl/rbf_check.go +++ b/ctl/rbf_check.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/rbf" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/rbf" ) // RBFCheckCommand represents a command for running a consistency check on RBF. diff --git a/ctl/rbf_dump.go b/ctl/rbf_dump.go index 992318de6..cfaa120e1 100644 --- a/ctl/rbf_dump.go +++ b/ctl/rbf_dump.go @@ -8,8 +8,8 @@ import ( "io" "strings" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/rbf" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/rbf" ) // RBFDumpCommand represents a command for dumping raw data for an RBF page. diff --git a/ctl/rbf_page.go b/ctl/rbf_page.go index 1af1e9335..eb0a71c7f 100644 --- a/ctl/rbf_page.go +++ b/ctl/rbf_page.go @@ -6,8 +6,8 @@ import ( "fmt" "io" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/rbf" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/rbf" ) // RBFPageCommand represents a command for printing data for a single RBF page. diff --git a/ctl/rbf_pages.go b/ctl/rbf_pages.go index b774175ae..75c6ba59a 100644 --- a/ctl/rbf_pages.go +++ b/ctl/rbf_pages.go @@ -6,9 +6,9 @@ import ( "fmt" "io" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/rbf" - "github.com/molecula/featurebase/v2/txkey" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/rbf" + "github.com/molecula/featurebase/v3/txkey" ) // RBFPagesCommand represents a command for printing a list of RBF page metadata. diff --git a/ctl/restore.go b/ctl/restore.go index 9c12434f8..b40b25b78 100644 --- a/ctl/restore.go +++ b/ctl/restore.go @@ -17,11 +17,11 @@ import ( "github.com/hashicorp/go-retryablehttp" - pilosa "github.com/molecula/featurebase/v2" - fb_http "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/topology" + pilosa "github.com/molecula/featurebase/v3" + fb_http "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) @@ -56,7 +56,7 @@ func NewRestoreCommand(stdin io.Reader, stdout, stderr io.Writer) *RestoreComman CmdIO: pilosa.NewCmdIO(stdin, stdout, stderr), RetryPeriod: time.Second * 30, Concurrency: 1, - Pprof: "localhost:43809", + Pprof: "localhost:0", } } diff --git a/ctl/server.go b/ctl/server.go index 74f5ad888..98391f761 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/storage" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/storage" "github.com/spf13/cobra" ) @@ -111,6 +111,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.StringVar(&srv.Config.Auth.ClientId, "auth.client-id", srv.Config.Auth.ClientId, "Identity Provider's Application/Client ID.") flags.StringVar(&srv.Config.Auth.ClientSecret, "auth.client-secret", srv.Config.Auth.ClientSecret, "Identity Provider's Client Secret.") flags.StringVar(&srv.Config.Auth.AuthorizeURL, "auth.authorize-url", srv.Config.Auth.AuthorizeURL, "Identity Provider's Authorize URL.") + flags.StringVar(&srv.Config.Auth.RedirectBaseURL, "auth.redirect-base-url", srv.Config.Auth.RedirectBaseURL, "Base URL of the featurebase instance used to redirect IDP.") flags.StringVar(&srv.Config.Auth.TokenURL, "auth.token-url", srv.Config.Auth.TokenURL, "Identity Provider's Token URL.") flags.StringVar(&srv.Config.Auth.GroupEndpointURL, "auth.group-endpoint-url", srv.Config.Auth.GroupEndpointURL, "Identity Provider's Group endpoint URL.") flags.StringVar(&srv.Config.Auth.LogoutURL, "auth.logout-url", srv.Config.Auth.LogoutURL, "Identity Provider's Logout URL.") diff --git a/ctl/server_test.go b/ctl/server_test.go index 18d8027e2..fc17e3050 100644 --- a/ctl/server_test.go +++ b/ctl/server_test.go @@ -5,7 +5,7 @@ import ( "bytes" "testing" - "github.com/molecula/featurebase/v2/server" + "github.com/molecula/featurebase/v3/server" "github.com/spf13/cobra" ) diff --git a/ctl/util.go b/ctl/util.go index 60ac082c9..4ee0762b0 100644 --- a/ctl/util.go +++ b/ctl/util.go @@ -9,7 +9,7 @@ import ( "time" "github.com/felixge/fgprof" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" "github.com/pkg/errors" ) @@ -40,7 +40,7 @@ func startProfilingServer(addr string, logger logger.Logger) (close func() error return nil, err } go func() { - logger.Printf("Listening for /debug/pprof/ and /debug/fgprof on '%s'", addr) + logger.Printf("Listening for /debug/pprof/ and /debug/fgprof on '%s'", ln.Addr().String()) logger.Printf("%v", s.Serve(ln)) }() diff --git a/dbshard.go b/dbshard.go index df43273dd..ee738458f 100644 --- a/dbshard.go +++ b/dbshard.go @@ -10,12 +10,12 @@ import ( "strings" "sync" - rbfcfg "github.com/molecula/featurebase/v2/rbf/cfg" - txkey "github.com/molecula/featurebase/v2/short_txkey" - "github.com/molecula/featurebase/v2/storage" + rbfcfg "github.com/molecula/featurebase/v3/rbf/cfg" + txkey "github.com/molecula/featurebase/v3/short_txkey" + "github.com/molecula/featurebase/v3/storage" "github.com/pkg/errors" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/vprint" ) var _ = sort.Sort diff --git a/dbshard_internal_test.go b/dbshard_internal_test.go index e524ae7e7..ceb63ab89 100644 --- a/dbshard_internal_test.go +++ b/dbshard_internal_test.go @@ -8,11 +8,11 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/rbf" - "github.com/molecula/featurebase/v2/shardwidth" - txkey "github.com/molecula/featurebase/v2/short_txkey" - "github.com/molecula/featurebase/v2/testhook" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v3/rbf" + "github.com/molecula/featurebase/v3/shardwidth" + txkey "github.com/molecula/featurebase/v3/short_txkey" + "github.com/molecula/featurebase/v3/testhook" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) // Shard per db evaluation diff --git a/dbshard_test.go b/dbshard_test.go index 62945b1fb..6f7281301 100644 --- a/dbshard_test.go +++ b/dbshard_test.go @@ -7,12 +7,12 @@ import ( "reflect" "testing" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) func TestAPI_SimplerOneNode_ImportColumnKey(t *testing.T) { diff --git a/delete_test.go b/delete_test.go index e3e1a2aef..df977513b 100644 --- a/delete_test.go +++ b/delete_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/test" "github.com/stretchr/testify/require" ) diff --git a/diagnostics.go b/diagnostics.go index 3742d6d88..989fc8e4c 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" "github.com/pkg/errors" ) diff --git a/diagnostics_internal_test.go b/diagnostics_internal_test.go index 690fba1de..0a0ccf8c9 100644 --- a/diagnostics_internal_test.go +++ b/diagnostics_internal_test.go @@ -10,7 +10,7 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" ) func TestDiagnosticsClient(t *testing.T) { diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index cb66619c3..b9f826938 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -6,14 +6,14 @@ import ( "time" "github.com/gogo/protobuf/proto" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/ingest" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/pb" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/topology" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/ingest" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/pb" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" ) diff --git a/encoding/proto/proto_test.go b/encoding/proto/proto_test.go index a011b6b41..6c2107fc5 100644 --- a/encoding/proto/proto_test.go +++ b/encoding/proto/proto_test.go @@ -6,9 +6,9 @@ import ( "reflect" "testing" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/pb" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/pb" ) func testOneRoundTrip(t *testing.T, s pilosa.Serializer, obj pilosa.Message, expectedMarshalErr error, expectedUnmarshalErr error, expectedMismatchErr error) { diff --git a/etcd/embed.go b/etcd/embed.go index db3bc34ea..cff332736 100644 --- a/etcd/embed.go +++ b/etcd/embed.go @@ -14,9 +14,9 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/topology" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" "go.etcd.io/etcd/clientv3" "go.etcd.io/etcd/clientv3/clientv3util" @@ -187,6 +187,22 @@ func (e *Etcd) Close() error { // New feature: retryClient can also retry on errTimeout. const etcdRetryTimes = 3 +// newClient requests a new client which is different from the one +// passed in. if we've already changed our client (say, because someone +// else already did that) we just return that new one. +func (e *Etcd) newClient(cli *clientv3.Client) *clientv3.Client { + e.cliMu.Lock() + defer e.cliMu.Unlock() + if cli != e.cli { + cli = e.cli + // someone else already reopened. retry. + return cli + } + _ = cli.Close() + e.cli = v3client.New(e.e.Server) + return e.cli +} + func (e *Etcd) retryClient(fn func(cli *clientv3.Client) error) (err error) { e.cliMu.Lock() cli := e.cli @@ -196,21 +212,25 @@ func (e *Etcd) retryClient(fn func(cli *clientv3.Client) error) (err error) { err = fn(cli) switch err { case etcdserver.ErrLeaderChanged: - // we can't do much with an error from closing e.cli at this point, so - // we try again. - e.cliMu.Lock() - if cli != e.cli { - cli = e.cli - e.cliMu.Unlock() - // someone else already reopened. retry. - continue - } - _ = cli.Close() - cli = v3client.New(e.e.Server) - e.cli = cli - e.cliMu.Unlock() + cli = e.newClient(cli) break - case etcdserver.ErrTimeout: + case nil: + return nil + default: + msg := err.Error() + // this shouldn't be necessary, but empirically, we sometimes + // get an error message which has this text, but the error itself + // isn't actually etcdserver.ErrLeaderChanged. + if strings.Contains(msg, "etcdserver: leader changed") { + cli = e.newClient(cli) + break + } + if !strings.Contains(msg, "etcdserver: request timed out") { + // not a known error, also not a wrapped timeout + return errors.Wrap(err, "non-retryable error") + } + fallthrough // treat this as being one of the ErrTimeout derivatives, possibly wrapped. + case etcdserver.ErrTimeout, etcdserver.ErrTimeoutDueToLeaderFail, etcdserver.ErrTimeoutDueToConnectionLost, etcdserver.ErrTimeoutLeaderTransfer: // sporadic timeouts are concerning but not necessarily fatal // and can usually be retried. elapsed := time.Since(start) @@ -225,9 +245,6 @@ func (e *Etcd) retryClient(fn func(cli *clientv3.Client) error) (err error) { // from spamming these. time.Sleep(100 * time.Millisecond) break - default: - // nil, or an error we don't know about - return errors.Wrap(err, "non-retryable error") } } // if we got here, we got a total of three of some combination of diff --git a/etcd/leasedkv.go b/etcd/leasedkv.go index 742bb51ad..20d8d40ed 100644 --- a/etcd/leasedkv.go +++ b/etcd/leasedkv.go @@ -7,7 +7,7 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/disco" + "github.com/molecula/featurebase/v3/disco" "github.com/pkg/errors" "go.etcd.io/etcd/clientv3" "go.etcd.io/etcd/clientv3/clientv3util" diff --git a/etcd/leasedkv_test.go b/etcd/leasedkv_test.go index 5d8a9444f..e4222764b 100644 --- a/etcd/leasedkv_test.go +++ b/etcd/leasedkv_test.go @@ -3,24 +3,57 @@ package etcd import ( "context" - "errors" + "fmt" + "net" "os" "testing" "time" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/testhook" + "github.com/pkg/errors" "go.etcd.io/etcd/embed" "go.etcd.io/etcd/etcdserver/api/v3client" + "go.etcd.io/etcd/pkg/types" ) const initVal = "test" const newVal = "newValue" +// listenerWithURL builds a TCP listener and corresponding http://localhost:%d +// URL, and returns those. Identical to the copy in /test, except we can't +// import that because it imports us. +func listenerWithURL() (listener *net.TCPListener, url string, err error) { + l, err := net.Listen("tcp", ":0") + if err != nil { + return listener, url, err + } + listener = l.(*net.TCPListener) + port := listener.Addr().(*net.TCPAddr).Port + url = fmt.Sprintf("http://localhost:%d", port) + return listener, url, err +} + func TestLeasedKv(t *testing.T) { cfg := embed.NewConfig() + clientListener, clientURL, err := listenerWithURL() + if err != nil { + t.Fatal(errors.Wrap(err, "creating client listener")) + } + peerListener, peerURL, err := listenerWithURL() + if err != nil { + t.Fatal(errors.Wrap(err, "creating peer listener")) + } + cfg.LPUrls = types.MustNewURLs([]string{peerURL}) + cfg.LPeerSocket = []*net.TCPListener{peerListener} + cfg.APUrls = types.MustNewURLs([]string{peerURL}) + cfg.LCUrls = types.MustNewURLs([]string{clientURL}) + cfg.LClientSocket = []*net.TCPListener{clientListener} + cfg.ACUrls = types.MustNewURLs([]string{clientURL}) + cfg.InitialCluster = cfg.Name + "=" + peerURL + dir, err := testhook.TempDir(t, "leasedkv-*") if err != nil { t.Fatal(err) diff --git a/event.go b/event.go index 83d2c3a03..811e6c7d9 100644 --- a/event.go +++ b/event.go @@ -1,7 +1,7 @@ // Copyright 2021 Molecula Corp. All rights reserved. package pilosa -import "github.com/molecula/featurebase/v2/topology" +import "github.com/molecula/featurebase/v3/topology" // NodeEventType are the types of node events. type NodeEventType int diff --git a/executor.go b/executor.go index 692feef82..24e36af61 100644 --- a/executor.go +++ b/executor.go @@ -17,14 +17,14 @@ import ( "unsafe" "github.com/lib/pq" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/proto" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/shardwidth" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/tracing" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/proto" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/shardwidth" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/topology" + "github.com/molecula/featurebase/v3/tracing" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/executor_internal_test.go b/executor_internal_test.go index 953123385..171cb2ae3 100644 --- a/executor_internal_test.go +++ b/executor_internal_test.go @@ -10,8 +10,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/testhook" ) func TestExecutor_TranslateRowsOnBool(t *testing.T) { diff --git a/executor_test.go b/executor_test.go index 990a569dd..a074cf90f 100644 --- a/executor_test.go +++ b/executor_test.go @@ -25,18 +25,18 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/ctl" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/proto" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/storage" - "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/testhook" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/ctl" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/proto" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/storage" + "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/testhook" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck "github.com/pkg/errors" ) diff --git a/field.go b/field.go index b78ed051c..5beb2983a 100644 --- a/field.go +++ b/field.go @@ -15,12 +15,12 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/tracing" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/tracing" "github.com/pkg/errors" ) diff --git a/field_internal_test.go b/field_internal_test.go index d9471db91..da1ba40bd 100644 --- a/field_internal_test.go +++ b/field_internal_test.go @@ -12,11 +12,11 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/shardwidth" - "github.com/molecula/featurebase/v2/testhook" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/shardwidth" + "github.com/molecula/featurebase/v3/testhook" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) // CorruptAMutex breaks a mutex in order to test the mutex-corruption stuff. diff --git a/field_test.go b/field_test.go index 739dc60a2..8eb4f8d3e 100644 --- a/field_test.go +++ b/field_test.go @@ -6,10 +6,10 @@ import ( "testing" "github.com/google/go-cmp/cmp" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/testhook" ) // Ensure a field can set & read a bsiGroup value. diff --git a/fragment.go b/fragment.go index cf04079e0..1eceb076f 100644 --- a/fragment.go +++ b/fragment.go @@ -27,17 +27,17 @@ import ( "github.com/cespare/xxhash" "github.com/gogo/protobuf/proto" - "github.com/molecula/featurebase/v2/logger" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/pb" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/shardwidth" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/tracing" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/logger" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/pb" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/shardwidth" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/topology" + "github.com/molecula/featurebase/v3/tracing" + "github.com/molecula/featurebase/v3/vprint" "github.com/pkg/errors" ) diff --git a/fragment_internal_test.go b/fragment_internal_test.go index 7945476c6..0ecdfb787 100644 --- a/fragment_internal_test.go +++ b/fragment_internal_test.go @@ -23,11 +23,11 @@ import ( "testing/quick" "github.com/davecgh/go-spew/spew" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/storage" - "github.com/molecula/featurebase/v2/testhook" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/storage" + "github.com/molecula/featurebase/v3/testhook" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/gcnotify/gcnotify.go b/gcnotify/gcnotify.go index fc9d90fa6..e6bf92eed 100644 --- a/gcnotify/gcnotify.go +++ b/gcnotify/gcnotify.go @@ -3,7 +3,7 @@ package gcnotify import ( "github.com/CAFxX/gcnotifier" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" ) // Ensure ActiveGCNotifier implements interface. diff --git a/gendebug_test.go b/gendebug_test.go index bc7fb488c..05094bd22 100644 --- a/gendebug_test.go +++ b/gendebug_test.go @@ -10,7 +10,7 @@ import ( "fmt" "runtime" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) func examineResults() error { diff --git a/generation.go b/generation.go index 7c880c8c3..dfb8a3277 100644 --- a/generation.go +++ b/generation.go @@ -12,9 +12,9 @@ import ( "syscall" "time" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/syswrap" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/syswrap" "github.com/pkg/errors" ) diff --git a/go.mod b/go.mod index f15095796..f1d6d285b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/molecula/featurebase/v2 +module github.com/molecula/featurebase/v3 replace go.etcd.io/etcd => github.com/molecula/etcd v0.0.0-20210930172242-ad94b354f72c @@ -14,7 +14,6 @@ require ( github.com/cespare/xxhash v1.1.0 github.com/davecgh/go-spew v1.1.1 github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dustin/go-humanize v1.0.0 // indirect github.com/felixge/fgprof v0.9.1 github.com/fsnotify/fsnotify v1.4.9 // indirect diff --git a/gopsutil/systeminfo.go b/gopsutil/systeminfo.go index f95a08e86..3430562b6 100644 --- a/gopsutil/systeminfo.go +++ b/gopsutil/systeminfo.go @@ -6,7 +6,7 @@ import ( "runtime" "strings" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" "github.com/shirou/gopsutil/v3/host" diff --git a/gopsutil/systeminfo_test.go b/gopsutil/systeminfo_test.go index f285f3a69..a59cedc03 100644 --- a/gopsutil/systeminfo_test.go +++ b/gopsutil/systeminfo_test.go @@ -4,8 +4,8 @@ package gopsutil_test import ( "testing" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/gopsutil" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/gopsutil" ) func TestSystemInfo(t *testing.T) { diff --git a/hack.go b/hack.go index 2fad99df2..4f8a8a460 100644 --- a/hack.go +++ b/hack.go @@ -3,8 +3,8 @@ package pilosa import ( "github.com/gogo/protobuf/proto" - "github.com/molecula/featurebase/v2/pb" - "github.com/molecula/featurebase/v2/pql" + "github.com/molecula/featurebase/v3/pb" + "github.com/molecula/featurebase/v3/pql" ) func UnmarshalIndexOptions(name string, createdAt int64, buf []byte) (*IndexOptions, error) { diff --git a/handler.go b/handler.go index ee18153ea..725225f5f 100644 --- a/handler.go +++ b/handler.go @@ -5,8 +5,8 @@ import ( "encoding/json" "time" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/tracing" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/tracing" "github.com/pkg/errors" ) diff --git a/hash/blake3_test.go b/hash/blake3_test.go index d33df7b4b..e7552f23a 100644 --- a/hash/blake3_test.go +++ b/hash/blake3_test.go @@ -9,7 +9,7 @@ import ( "path" "testing" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) func TestBlake3Hasher(t *testing.T) { diff --git a/holder.go b/holder.go index ad50e497e..cf35bf998 100644 --- a/holder.go +++ b/holder.go @@ -15,15 +15,15 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/logger" - rbfcfg "github.com/molecula/featurebase/v2/rbf/cfg" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/storage" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/logger" + rbfcfg "github.com/molecula/featurebase/v3/rbf/cfg" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/storage" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/topology" + "github.com/molecula/featurebase/v3/vprint" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/holder_internal_test.go b/holder_internal_test.go index e2724ac50..b1455aa5e 100644 --- a/holder_internal_test.go +++ b/holder_internal_test.go @@ -7,8 +7,8 @@ import ( "os" "testing" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/testhook" ) var _ = fmt.Printf diff --git a/holder_test.go b/holder_test.go index 01b6db39f..cff3cf7da 100644 --- a/holder_test.go +++ b/holder_test.go @@ -11,10 +11,10 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/test" "github.com/pkg/errors" ) diff --git a/http/client.go b/http/client.go index c9bf14068..183b7675d 100644 --- a/http/client.go +++ b/http/client.go @@ -20,14 +20,14 @@ import ( "time" "github.com/hashicorp/go-retryablehttp" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/authn" - "github.com/molecula/featurebase/v2/encoding/proto" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/logger" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/tracing" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/authn" + "github.com/molecula/featurebase/v3/encoding/proto" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/logger" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/topology" + "github.com/molecula/featurebase/v3/tracing" "github.com/pkg/errors" ) diff --git a/http/client_test.go b/http/client_test.go index 0b05bc00f..74c25d7fd 100644 --- a/http/client_test.go +++ b/http/client_test.go @@ -14,12 +14,12 @@ import ( "time" "github.com/davecgh/go-spew/spew" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/topology" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" ) diff --git a/http/handler.go b/http/handler.go index 579f66385..1dbf32c68 100644 --- a/http/handler.go +++ b/http/handler.go @@ -29,16 +29,16 @@ import ( "github.com/felixge/fgprof" "github.com/gorilla/handlers" "github.com/gorilla/mux" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/authn" - "github.com/molecula/featurebase/v2/authz" - "github.com/molecula/featurebase/v2/encoding/proto" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/rbf" - "github.com/molecula/featurebase/v2/topology" - "github.com/molecula/featurebase/v2/tracing" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/authn" + "github.com/molecula/featurebase/v3/authz" + "github.com/molecula/featurebase/v3/encoding/proto" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/rbf" + "github.com/molecula/featurebase/v3/topology" + "github.com/molecula/featurebase/v3/tracing" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus/promhttp" dto "github.com/prometheus/client_model/go" @@ -544,9 +544,13 @@ func (h *Handler) chkInternal(handler http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if h.auth != nil { secret, ok := r.Header["X-Feature-Key"] - decodedString, err := hex.DecodeString(secret[0]) + secretString := "" + if ok { + secretString = secret[0] + } + decodedString, err := hex.DecodeString(secretString) if err != nil || !ok || !bytes.Equal(decodedString, h.auth.SecretKey()) { - http.Error(w, errors.Wrap(err, "internal secret key validation failed").Error(), http.StatusUnauthorized) + http.Error(w, "internal secret key validation failed", http.StatusUnauthorized) return } } diff --git a/http/handler_internal_test.go b/http/handler_internal_test.go index 511079961..25173ede6 100644 --- a/http/handler_internal_test.go +++ b/http/handler_internal_test.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "encoding/json" "io/ioutil" + "net/http" gohttp "net/http" "net/http/httptest" "net/url" @@ -16,13 +17,13 @@ import ( "time" "github.com/golang-jwt/jwt" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/authn" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/authn" "golang.org/x/oauth2" - "github.com/molecula/featurebase/v2/authz" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/pql" + "github.com/molecula/featurebase/v3/authz" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/pql" ) // Test custom UnmarshalJSON for postIndexRequest object @@ -235,7 +236,7 @@ func TestAuthentication(t *testing.T) { claims["name"] = "todd" validToken, err := tkn.SignedString([]byte(secretKey)) if err != nil { - panic(err) + t.Fatal(err) } validToken = "Bearer " + validToken @@ -247,15 +248,10 @@ func TestAuthentication(t *testing.T) { } // make an expired token - expiredTkn := jwt.New(jwt.SigningMethodHS256) - expiredClaims := expiredTkn.Claims.(jwt.MapClaims) - expiredClaims["molecula-idp-groups"] = groupString - expiredClaims["oid"] = "42" - expiredClaims["name"] = "todd" - expiredClaims["exp"] = "1" - expiredToken, err := expiredTkn.SignedString([]byte(secretKey)) + claims["exp"] = "1" + expiredToken, err := tkn.SignedString([]byte(secretKey)) if err != nil { - panic(err) + t.Fatal(err) } expiredToken = "Bearer " + expiredToken @@ -502,9 +498,7 @@ admin: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe"` }, }, { - // this tests that there are no permissions read in even though - // auth is turned on, so we get a 500 - name: "MW-CreateIndexGood", + name: "MW-CreateIndexInsufficientPerms", path: "/index/abcd", kind: "bearer", method: gohttp.MethodPost, @@ -622,3 +616,172 @@ admin: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe"` } } + +func TestChkAuthN(t *testing.T) { + a := NewTestAuth(t) + h := Handler{ + logger: logger.NewStandardLogger(os.Stdout), + queryLogger: logger.NewStandardLogger(os.Stdout), + auth: a, + } + + // make a valid token + tkn := jwt.New(jwt.SigningMethodHS256) + claims := tkn.Claims.(jwt.MapClaims) + groupString, _ := authn.ToGob64([]authn.Group{{GroupID: "thing", GroupName: "whatever"}}) + claims["molecula-idp-groups"] = groupString + claims["oid"] = "42" + claims["name"] = "A. Token" + validToken, err := tkn.SignedString(a.SecretKey()) + if err != nil { + t.Fatal(err) + } + validToken = "Bearer " + validToken + + // make an invalid token + invalidKey, err := hex.DecodeString("DEADBEEDDEADBEEDDEADBEEDDEADBEEDDEADBEEDDEADBEEDDEADBEEDDEADBEED") + if err != nil { + t.Fatal(err) + } + invalidToken, err := tkn.SignedString(invalidKey) + if err != nil { + t.Fatal(err) + } + invalidToken = "Bearer " + invalidToken + + // make an expired token + claims["exp"] = "1" + expiredToken, err := tkn.SignedString(a.SecretKey()) + if err != nil { + t.Fatal(err) + } + expiredToken = "Bearer " + expiredToken + + testingHandler := func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("good")) + } + + cases := []struct { + name string + endpoint string + token string + handler http.HandlerFunc + statusCode int + }{ + { + name: "Valid", + token: validToken, + handler: h.chkAuthN(testingHandler), + statusCode: http.StatusOK, + }, + { + name: "Invalid", + token: invalidToken, + handler: h.chkAuthN(testingHandler), + statusCode: http.StatusUnauthorized, + }, + { + name: "Expired", + token: expiredToken, + handler: h.chkAuthN(testingHandler), + statusCode: http.StatusUnauthorized, + }, + } + for _, test := range cases { + t.Run(test.name, func(t *testing.T) { + w := httptest.NewRecorder() + r := httptest.NewRequest("GET", "/whatever", nil) + r.Header.Add("Authorization", test.token) + test.handler(w, r) + resp := w.Result() + if resp.StatusCode != test.statusCode { + t.Fatalf("expected %v, got %v", test.statusCode, resp.StatusCode) + } + }) + } +} + +func TestChkInternal(t *testing.T) { + a := NewTestAuth(t) + authKey := "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF" + h := Handler{ + logger: logger.NewStandardLogger(os.Stdout), + queryLogger: logger.NewStandardLogger(os.Stdout), + auth: a, + } + + testingHandler := func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("good")) + } + + cases := []struct { + name string + statusCode int + handler http.HandlerFunc + key string + }{ + { + name: "happyPath", + statusCode: http.StatusOK, + handler: h.chkInternal(testingHandler), + key: authKey, + }, + { + name: "unhappyPath-empty", + statusCode: http.StatusUnauthorized, + handler: h.chkInternal(testingHandler), + key: "", + }, + { + name: "unhappyPath-wrong", + statusCode: http.StatusUnauthorized, + handler: h.chkInternal(testingHandler), + key: "BEABBEEFBEABBEEFBEABBEEFBEABBEEFBEABBEEFBEABBEEFBEABBEEFBEABBEEF", + }, + } + for _, test := range cases { + t.Run(test.name, func(t *testing.T) { + w := httptest.NewRecorder() + r := httptest.NewRequest("GET", "/whatever", nil) + if test.key != "" { + r.Header.Add("X-Feature-Key", test.key) + } + test.handler(w, r) + resp := w.Result() + if resp.StatusCode != test.statusCode { + t.Fatalf("expected %v, got %v", test.statusCode, resp.StatusCode) + } + }) + } +} + +func NewTestAuth(t *testing.T) *authn.Auth { + t.Helper() + var ( + ClientID = "e9088663-eb08-41d7-8f65-efb5f54bbb71" + ClientSecret = "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF" + AuthorizeURL = "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/authorize" + TokenURL = "https://login.microsoftonline.com/4a137d66-d161-4ae4-b1e6-07e9920874b8/oauth2/v2.0/token" + GroupEndpointURL = "https://graph.microsoft.com/v1.0/me/transitiveMemberOf/microsoft.graph.group?$count=true" + LogoutURL = "https://login.microsoftonline.com/common/oauth2/v2.0/logout" + Scopes = []string{"https://graph.microsoft.com/.default", "offline_access"} + Key = "DEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF" + ) + + a, err := authn.NewAuth( + logger.NewStandardLogger(os.Stdout), + "http://localhost:10101/", + Scopes, + AuthorizeURL, + TokenURL, + GroupEndpointURL, + LogoutURL, + ClientID, + ClientSecret, + Key, + ) + if err != nil { + t.Fatalf("building auth object%s", err) + } + return a +} diff --git a/http/handler_test.go b/http/handler_test.go index 7dd2e6b00..c58a4bd3e 100644 --- a/http/handler_test.go +++ b/http/handler_test.go @@ -9,10 +9,10 @@ import ( "strings" "testing" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" ) func TestHandlerOptions(t *testing.T) { diff --git a/http/translator.go b/http/translator.go index 8bce04a67..4c161d590 100644 --- a/http/translator.go +++ b/http/translator.go @@ -12,8 +12,8 @@ import ( "reflect" "sync" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/logger" ) func GetOpenTranslateReaderFunc(client *http.Client) pilosa.OpenTranslateReaderFunc { diff --git a/http/translator_test.go b/http/translator_test.go index 2474da7f1..74a579f9c 100644 --- a/http/translator_test.go +++ b/http/translator_test.go @@ -8,9 +8,9 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/test" ) func TestTranslateStore_EntryReader(t *testing.T) { diff --git a/idalloc_test.go b/idalloc_test.go index 69d7e5e3e..1004dc229 100644 --- a/idalloc_test.go +++ b/idalloc_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" bolt "go.etcd.io/bbolt" ) diff --git a/index.go b/index.go index 3426b3b5a..864e71346 100644 --- a/index.go +++ b/index.go @@ -10,10 +10,10 @@ import ( "strconv" "sync" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/testhook" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/index_internal_test.go b/index_internal_test.go index 161e7a2d3..a36a2475a 100644 --- a/index_internal_test.go +++ b/index_internal_test.go @@ -4,7 +4,7 @@ package pilosa import ( "testing" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) // mustOpenIndex returns a new, opened index at a temporary path. Panic on error. diff --git a/index_test.go b/index_test.go index 6d2a7a0c6..67d69ecbe 100644 --- a/index_test.go +++ b/index_test.go @@ -10,11 +10,11 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/testhook" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/testhook" "github.com/pkg/errors" ) diff --git a/ingest/codec_test.go b/ingest/codec_test.go index 04d81c558..d36a0b757 100644 --- a/ingest/codec_test.go +++ b/ingest/codec_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) func TestStableTranslator(t *testing.T) { diff --git a/ingest/op.go b/ingest/op.go index df5291a39..5eb3880ca 100644 --- a/ingest/op.go +++ b/ingest/op.go @@ -7,7 +7,7 @@ import ( "math/bits" "sort" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) type OpType uint8 diff --git a/ingest/op_test.go b/ingest/op_test.go index dadf04d0f..31e1c56ff 100644 --- a/ingest/op_test.go +++ b/ingest/op_test.go @@ -5,7 +5,7 @@ import ( "math/rand" "testing" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) type opShardingTestCase struct { diff --git a/ingest/update.go b/ingest/update.go index c27448eac..f36363ba7 100644 --- a/ingest/update.go +++ b/ingest/update.go @@ -2,7 +2,7 @@ package ingest import ( - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/roaring" ) // ShardUpdate is an update request for a shard. diff --git a/ingest_test.go b/ingest_test.go index cca87e258..712b834e6 100644 --- a/ingest_test.go +++ b/ingest_test.go @@ -12,9 +12,9 @@ import ( "strings" "testing" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/test" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/test" "github.com/pkg/errors" ) diff --git a/install/featurebase.conf b/install/featurebase.conf index 3389ff90d..a8894e8f9 100644 --- a/install/featurebase.conf +++ b/install/featurebase.conf @@ -381,6 +381,7 @@ log-path = "/var/log/molecula/featurebase.log" # authorize-url = "" # token-url = "" # group-endpoint-url = "" +# redirect-base-url = "" # logout-url = "" # scopes = ["", ""] # secret-key = "" diff --git a/internal/clustertests/cluster_test.go b/internal/clustertests/cluster_test.go index 79d067ad4..c6f4b0c3b 100644 --- a/internal/clustertests/cluster_test.go +++ b/internal/clustertests/cluster_test.go @@ -11,9 +11,9 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/disco" - picli "github.com/molecula/featurebase/v2/http" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/disco" + picli "github.com/molecula/featurebase/v3/http" ) func TestClusterStuff(t *testing.T) { diff --git a/internal/clustertests/docker-compose.yml b/internal/clustertests/docker-compose.yml index 46143a3f6..af74a4d30 100644 --- a/internal/clustertests/docker-compose.yml +++ b/internal/clustertests/docker-compose.yml @@ -75,6 +75,6 @@ services: volumes: - /var/run/docker.sock:/var/run/docker.sock command: - - "cd /go/src/github.com/molecula/featurebase/ && go test -mod=vendor -v -count=1 github.com/molecula/featurebase/v2/internal/clustertests" + - "cd /go/src/github.com/molecula/featurebase/ && go test -mod=vendor -v -count=1 github.com/molecula/featurebase/v3/internal/clustertests" networks: pilosanet: diff --git a/internal/clustertests/pause_node_test.go b/internal/clustertests/pause_node_test.go index 256078a90..d6c3863a8 100644 --- a/internal/clustertests/pause_node_test.go +++ b/internal/clustertests/pause_node_test.go @@ -14,12 +14,12 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - boltdb "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/topology" + pilosa "github.com/molecula/featurebase/v3" + boltdb "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" ) diff --git a/internal/test/querygenerator.go b/internal/test/querygenerator.go index f85811ed7..2be0e4874 100644 --- a/internal/test/querygenerator.go +++ b/internal/test/querygenerator.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/molecula/featurebase/v2/pql" + "github.com/molecula/featurebase/v3/pql" ) type Args map[string]interface{} diff --git a/internal/test/querygenerator_test.go b/internal/test/querygenerator_test.go index 766e62a80..9b62586a3 100644 --- a/internal/test/querygenerator_test.go +++ b/internal/test/querygenerator_test.go @@ -4,7 +4,7 @@ package test import ( "testing" - "github.com/molecula/featurebase/v2/pql" + "github.com/molecula/featurebase/v3/pql" ) func TestPQL_Generator(t *testing.T) { diff --git a/iterator.go b/iterator.go index b37c44062..0364ae28e 100644 --- a/iterator.go +++ b/iterator.go @@ -4,7 +4,7 @@ package pilosa import ( "fmt" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/roaring" ) // iterator is an interface for looping over row/column pairs. diff --git a/lattice/src/App/AuthFlow/SignOutButton.tsx b/lattice/src/App/AuthFlow/SignOutButton.tsx index 3e76c22db..ff6b5e6ba 100644 --- a/lattice/src/App/AuthFlow/SignOutButton.tsx +++ b/lattice/src/App/AuthFlow/SignOutButton.tsx @@ -7,6 +7,7 @@ interface Props { const SignOutButton: React.FC = ({ children }) => { const signoutOnClick = (e) => { + localStorage.clear(); window.location.href = '/logout'; }; diff --git a/lattice/src/App/QueryBuilder/QueryBuilderContainer.tsx b/lattice/src/App/QueryBuilder/QueryBuilderContainer.tsx index da27904de..3f7afb292 100644 --- a/lattice/src/App/QueryBuilder/QueryBuilderContainer.tsx +++ b/lattice/src/App/QueryBuilder/QueryBuilderContainer.tsx @@ -196,7 +196,8 @@ export const QueryBuilderContainer = () => { return ( - {tables.length > 0 ? ( + {/* check if tables is not null AND tables.length > 0 */} + {(tables && tables.length > 0) ? ( 0 { var pass []uint32 pass, tx.pendingFreelistAdds = tx.pendingFreelistAdds, nil @@ -1006,7 +1009,7 @@ func (tx *Tx) freelistCleanup(outErr *error) { } return } else if !changed { - vprint.PanicOn(fmt.Sprintf("rbf.Tx.freePgno(): double free: %d", tx.pendingFreelistAdds)) + vprint.PanicOn(fmt.Sprintf("rbf.Tx.freelistCleanup(): double free: %d", pass)) } } } @@ -1015,44 +1018,25 @@ func (tx *Tx) freelistCleanup(outErr *error) { // allocatePgno returns a page number for a new available page. This page may be // pulled from the free list or, if no free pages are available, it will be // created by extending the file size. +// +// allocatePgno uses the freelist cursor (a shared db-wide thing), and sets +// the "modifyingFreelist" flag while it's running. If for some reason a +// modification to the freelist would require a new allocation or free, +// allocations always just create a new page, and frees are processed later +// by a separate call through a deferred tx.freelistCleanup(). func (tx *Tx) allocatePgno() (_ uint32, outErr error) { if tx.modifyingFreelist { return tx.allocateNewPgno(), nil } - // Attempt to find page in freelist. - pgno, err := tx.nextFreelistPageNo() - - if err != nil { - return 0, err - } else if pgno != 0 { - tx.modifyingFreelist = true - defer tx.freelistCleanup(&outErr) - c := Cursor{tx: tx} - c.stack.elems[0] = stackElem{pgno: readMetaFreelistPageNo(tx.meta[:])} - if changed, err := c.Remove(uint64(pgno)); err != nil { - return 0, err - } else if !changed { - vprint.PanicOn(fmt.Sprintf("tx.Tx.allocatePgno(): double alloc: %d", pgno)) - } - return pgno, nil - } - // no freelist pages, fall back - return tx.allocateNewPgno(), nil -} - -// allocateNewPgno requests a new page unconditionally, ignoring the free list. -func (tx *Tx) allocateNewPgno() uint32 { - // Increment the total page count by one and return the last page. - pgno := readMetaPageN(tx.meta[:]) - writeMetaPageN(tx.meta[:], pgno+1) - return pgno -} - -func (tx *Tx) nextFreelistPageNo() (uint32, error) { - c := Cursor{tx: tx} - c.stack.elems[0] = stackElem{pgno: readMetaFreelistPageNo(tx.meta[:])} + // this serves as a precaution against double-use of the freelist cursor + // used database-wide. we don't have actual synchronization here because + // only one write Tx should exist at once and it's not safe to use its + // write-capable ops concurrently anyway. + tx.modifyingFreelist = true + defer tx.freelistCleanup(&outErr) + c := tx.db.getFreelistCursor(tx) if err := c.First(); err == io.EOF { - return 0, nil + return tx.allocateNewPgno(), nil } else if err != nil { return 0, err } @@ -1067,17 +1051,30 @@ func (tx *Tx) nextFreelistPageNo() (uint32, error) { v := cell.firstValue(tx) pgno := uint32((cell.Key << 16) | uint64(v)) + + if changed, err := c.Remove(uint64(pgno)); err != nil { + return 0, err + } else if !changed { + vprint.PanicOn(fmt.Sprintf("tx.Tx.allocatePgno(): double alloc: %d", pgno)) + } return pgno, nil } +// allocateNewPgno requests a new page unconditionally, ignoring the free list. +func (tx *Tx) allocateNewPgno() uint32 { + // Increment the total page count by one and return the last page. + pgno := readMetaPageN(tx.meta[:]) + writeMetaPageN(tx.meta[:], pgno+1) + return pgno +} + // deallocate releases a page number to the freelist. func (tx *Tx) freePgno(pgno uint32) (outErr error) { if tx.modifyingFreelist { tx.pendingFreelistAdds = append(tx.pendingFreelistAdds, pgno) return nil } - c := Cursor{tx: tx} - c.stack.elems[0] = stackElem{pgno: readMetaFreelistPageNo(tx.meta[:])} + c := tx.db.getFreelistCursor(tx) tx.modifyingFreelist = true defer tx.freelistCleanup(&outErr) @@ -1800,9 +1797,16 @@ func (tx *Tx) flush() error { } // Write bitmap headers & pages to WAL. + // + // We need to write a bitmap header before each such page. We only allocate + // one header, and we reuse it, because each write is flushing it out to + // disk, and it doesn't get stored in-memory. + var hdr []byte + if len(tx.dirtyBitmapPages) > 0 { + hdr = allocPage() + } for _, pgno := range dirtyPageMapKeys(tx.dirtyBitmapPages) { // Write header page. - hdr := make([]byte, PageSize) writePageNo(hdr[:], pgno) writeFlags(hdr[:], PageTypeBitmapHeader) if _, err := tx.writeToWAL(w, hdr); err != nil { diff --git a/rbf/tx_test.go b/rbf/tx_test.go index 7a726c2ed..e9e493afc 100644 --- a/rbf/tx_test.go +++ b/rbf/tx_test.go @@ -12,8 +12,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/rbf" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/rbf" + "github.com/molecula/featurebase/v3/roaring" ) func TestTx_CommitRollback(t *testing.T) { @@ -140,14 +140,14 @@ func TestTx_CommitRollback(t *testing.T) { select { case <-ch1: t.Fatal("second tx started while first tx active") - case <-time.After(10 * time.Millisecond): + case <-time.After(50 * time.Millisecond): } // Finish first transaction. close(ch0) select { case <-ch1: - case <-time.After(10 * time.Millisecond): + case <-time.After(10 * time.Second): t.Fatal("second tx should have started after first tx closed") } }) @@ -248,6 +248,27 @@ func TestTx_DeallocateTree(t *testing.T) { } } +func arraySizedChunk() []uint16 { + v := make([]uint16, rbf.ArrayMaxSize) + for i := range v { + v[i] = uint16(i) + } + return v +} + +var convenientPrepopulatedArray = arraySizedChunk() + +// populateBitmapWithArrays +func populateBitmapWithArrays(tb testing.TB, tx *rbf.Tx, n int, name string) { + c := roaring.NewContainerArray(convenientPrepopulatedArray) + for i := 0; i < n; i++ { + err := tx.PutContainer(name, uint64(i), c) + if err != nil { + tb.Fatal(err) + } + } +} + func TestTx_RecreateBitmap(t *testing.T) { db := MustOpenDB(t) defer MustCloseDB(t, db) @@ -258,14 +279,8 @@ func TestTx_RecreateBitmap(t *testing.T) { if err := tx.CreateBitmap("x"); err != nil { t.Fatal(err) } - const N = 825000 - slots := make([]uint64, N) - for i := range slots { - slots[i] = uint64(i) << 20 - } - if _, err := tx.Add("x", slots...); err != nil { - t.Fatal(err) - } + const N = 825 + populateBitmapWithArrays(t, tx, N, "x") err := tx.Commit() if err != nil { t.Fatal(err) @@ -291,9 +306,7 @@ func TestTx_RecreateBitmap(t *testing.T) { if err := tx.CreateBitmap("x"); err != nil { t.Fatal(err) } - if _, err := tx.Add("x", slots...); err != nil { - t.Fatal(err) - } + populateBitmapWithArrays(t, tx, N, "x") err = tx.Commit() if err != nil { t.Fatal(err) @@ -374,20 +387,14 @@ func TestTx_DeallocateToFreeList(t *testing.T) { if err = tx.CreateBitmap("y"); err != nil { t.Fatal(err) } - const N = 12274831 - slots := make([]uint64, N) - for i := range slots { - slots[i] = uint64(i) << 10 - } - bm := roaring.NewBitmap(slots...) - if _, err = tx.AddRoaring("x", bm); err != nil { - t.Fatal(err) - } + // Insert large array values. + populateBitmapWithArrays(t, tx, 4080, "x") + if err = tx.Check(); err != nil { t.Fatal(err) } for i := 0; i < 500; i++ { - if _, err := tx.Add("y", uint64(i)<<16); err != nil { + if _, err := tx.Add("y", uint64(i)<<16+32768); err != nil { t.Fatal(err) } } @@ -426,9 +433,8 @@ func TestTx_DeallocateToFreeList(t *testing.T) { if err := tx.CreateBitmap("x"); err != nil { t.Fatal(err) } - if _, err := tx.AddRoaring("x", bm); err != nil { - t.Fatal(err) - } + populateBitmapWithArrays(t, tx, 4080, "x") + if err = tx.Check(); err != nil { t.Fatal(err) } @@ -451,17 +457,7 @@ func TestTx_Remove(t *testing.T) { } // Insert large array values. - var values []uint64 - for i := 0; i < 1000; i++ { - for j := 0; j < rbf.ArrayMaxSize; j++ { - v := uint64((i << 16) + j) - values = append(values, v) - - if _, err := tx.Add("x", v); err != nil { - t.Fatalf("Add(%d) err=%q", v, err) - } - } - } + populateBitmapWithArrays(t, tx, 500, "x") if err := tx.Commit(); err != nil { t.Fatal(err) @@ -471,12 +467,17 @@ func TestTx_Remove(t *testing.T) { defer tx.Rollback() // Remove all array values. - for _, i := range rand.Perm(len(values)) { - v := values[i] - if _, err := tx.Remove("x", v); err != nil { - t.Fatalf("Remove(%d) err=%q", v, err) + for i := 0; i < 500; i++ { + err := tx.RemoveContainer("x", uint64(i)) + if err != nil { + t.Fatal(err) } } + // This triggered a different panic without the relevant patch. + err := tx.RemoveContainer("x", 500) + if err != nil { + t.Fatal(err) + } if err := tx.Commit(); err != nil { t.Fatal(err) diff --git a/rbf/util.go b/rbf/util.go index 626b97738..4b29b2a2e 100644 --- a/rbf/util.go +++ b/rbf/util.go @@ -5,8 +5,8 @@ import ( "fmt" "strings" - txkey "github.com/molecula/featurebase/v2/short_txkey" - "github.com/molecula/featurebase/v2/vprint" + txkey "github.com/molecula/featurebase/v3/short_txkey" + "github.com/molecula/featurebase/v3/vprint" ) // we don't currently use dumpAllPages but it's tricky enough to get right diff --git a/rbf/util_test.go b/rbf/util_test.go index e13cc6acf..4a8177aff 100644 --- a/rbf/util_test.go +++ b/rbf/util_test.go @@ -7,9 +7,9 @@ import ( "os" "testing" - rbfcfg "github.com/molecula/featurebase/v2/rbf/cfg" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/testhook" + rbfcfg "github.com/molecula/featurebase/v3/rbf/cfg" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/testhook" ) // util_test adds reusable utilities for testing. diff --git a/roaring/benchpretty/main.go b/roaring/benchpretty/main.go index 20c790f6c..229eb39df 100644 --- a/roaring/benchpretty/main.go +++ b/roaring/benchpretty/main.go @@ -11,7 +11,7 @@ import ( "strconv" "strings" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/roaring" ) var pattern = regexp.MustCompile(`^BenchmarkCtOps/([^/]+)/([^/]+)/([^-]+)-([0-9]+)\s*([0-9]+)\s*([0-9.]+) ns/op`) diff --git a/roaring/filter.go b/roaring/filter.go index 600de65da..15a4a2f90 100644 --- a/roaring/filter.go +++ b/roaring/filter.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) // We want BitmapScanner to be accessible from both the pilosa package, and diff --git a/roaring/filter_internal_test.go b/roaring/filter_internal_test.go index c390741d6..1e9a5d778 100644 --- a/roaring/filter_internal_test.go +++ b/roaring/filter_internal_test.go @@ -9,7 +9,7 @@ import ( "sync" "testing" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) // For each container key i from 1 to (shard width in containers), we diff --git a/roaring/printutil.go b/roaring/printutil.go index bffd3b0b0..6cebb192d 100644 --- a/roaring/printutil.go +++ b/roaring/printutil.go @@ -5,7 +5,7 @@ import ( "fmt" "math" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) func (b *Bitmap) String() (r string) { diff --git a/roaring/printutil_test.go b/roaring/printutil_test.go index 44cbb6acc..27d2cbb58 100644 --- a/roaring/printutil_test.go +++ b/roaring/printutil_test.go @@ -5,7 +5,7 @@ import ( "fmt" "testing" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) func TestAsContainerMatrixString(t *testing.T) { diff --git a/roaring/roaring_internal_test.go b/roaring/roaring_internal_test.go index ba59b7ce4..7fc0e5bb1 100644 --- a/roaring/roaring_internal_test.go +++ b/roaring/roaring_internal_test.go @@ -12,7 +12,7 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/generator" + "github.com/molecula/featurebase/v3/generator" "github.com/pkg/errors" ) diff --git a/roaring/roaring_stats.go b/roaring/roaring_stats.go index eac3909f1..b0218bfcc 100644 --- a/roaring/roaring_stats.go +++ b/roaring/roaring_stats.go @@ -5,7 +5,7 @@ package roaring import ( - "github.com/molecula/featurebase/v2/stats" + "github.com/molecula/featurebase/v3/stats" ) var statsEv = stats.NewExpvarStatsClient() diff --git a/roaring/roaring_test.go b/roaring/roaring_test.go index 86e9ea516..508505b38 100644 --- a/roaring/roaring_test.go +++ b/roaring/roaring_test.go @@ -11,10 +11,10 @@ import ( "testing/quick" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/generator" - "github.com/molecula/featurebase/v2/roaring" - _ "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/generator" + "github.com/molecula/featurebase/v3/roaring" + _ "github.com/molecula/featurebase/v3/test" ) func TestContainerCount(t *testing.T) { diff --git a/row.go b/row.go index 60c14566f..b310d2ad0 100644 --- a/row.go +++ b/row.go @@ -5,8 +5,8 @@ import ( "encoding/json" "sort" - pb "github.com/molecula/featurebase/v2/proto" - "github.com/molecula/featurebase/v2/roaring" + pb "github.com/molecula/featurebase/v3/proto" + "github.com/molecula/featurebase/v3/roaring" "github.com/pkg/errors" ) diff --git a/row_test.go b/row_test.go index c4199a452..076026313 100644 --- a/row_test.go +++ b/row_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" ) // Ensure a row can be merged diff --git a/rrtx.go b/rrtx.go index be55f1893..0411e9c80 100644 --- a/rrtx.go +++ b/rrtx.go @@ -11,11 +11,11 @@ import ( "sync" "sync/atomic" - "github.com/molecula/featurebase/v2/roaring" - txkey "github.com/molecula/featurebase/v2/short_txkey" - "github.com/molecula/featurebase/v2/storage" + "github.com/molecula/featurebase/v3/roaring" + txkey "github.com/molecula/featurebase/v3/short_txkey" + "github.com/molecula/featurebase/v3/storage" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/vprint" "github.com/pkg/errors" ) diff --git a/rrtx_internal_test.go b/rrtx_internal_test.go index eb3907cd1..64c996bc4 100644 --- a/rrtx_internal_test.go +++ b/rrtx_internal_test.go @@ -4,7 +4,7 @@ package pilosa import ( "testing" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) func TestRoaring_HasData(t *testing.T) { diff --git a/server.go b/server.go index 23e760e19..076142a9a 100644 --- a/server.go +++ b/server.go @@ -17,15 +17,15 @@ import ( uuid "github.com/satori/go.uuid" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/logger" - pnet "github.com/molecula/featurebase/v2/net" - rbfcfg "github.com/molecula/featurebase/v2/rbf/cfg" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/sql2" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/storage" - "github.com/molecula/featurebase/v2/topology" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/logger" + pnet "github.com/molecula/featurebase/v3/net" + rbfcfg "github.com/molecula/featurebase/v3/rbf/cfg" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/sql2" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/storage" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" "golang.org/x/sync/errgroup" diff --git a/server/cluster_test.go b/server/cluster_test.go index 07ab7ea04..1f021bdf0 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -12,10 +12,10 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" ) // Ensure program can send/receive broadcast messages. diff --git a/server/config.go b/server/config.go index e3fe21fe3..8c6d4600b 100644 --- a/server/config.go +++ b/server/config.go @@ -15,11 +15,11 @@ import ( "strings" "time" - "github.com/molecula/featurebase/v2/authz" - petcd "github.com/molecula/featurebase/v2/etcd" - rbfcfg "github.com/molecula/featurebase/v2/rbf/cfg" - "github.com/molecula/featurebase/v2/storage" - "github.com/molecula/featurebase/v2/toml" + "github.com/molecula/featurebase/v3/authz" + petcd "github.com/molecula/featurebase/v3/etcd" + rbfcfg "github.com/molecula/featurebase/v3/rbf/cfg" + "github.com/molecula/featurebase/v3/storage" + "github.com/molecula/featurebase/v3/toml" "github.com/pkg/errors" ) @@ -240,6 +240,7 @@ type Auth struct { AuthorizeURL string `toml:"authorize-url"` TokenURL string `toml:"token-url"` GroupEndpointURL string `toml:"group-endpoint-url"` + RedirectBaseURL string `toml:"redirect-base-url"` LogoutURL string `toml:"logout-url"` Scopes []string `toml:"scopes"` SecretKey string `toml:"secret-key"` @@ -622,6 +623,7 @@ func (c *Config) ValidateAuth() (errors []error) { {name: "AuthorizeURL", val: c.Auth.AuthorizeURL}, {name: "TokenURL", val: c.Auth.TokenURL}, {name: "GroupEndpointURL", val: c.Auth.GroupEndpointURL}, + {name: "RedirectBaseURL", val: c.Auth.RedirectBaseURL}, {name: "LogoutURL", val: c.Auth.LogoutURL}, {name: "SecretKey", val: c.Auth.SecretKey}, {name: "QueryLogPath", val: c.Auth.QueryLogPath}, diff --git a/server/config_internal_test.go b/server/config_internal_test.go index 0dcf3ffb4..b12b58bff 100644 --- a/server/config_internal_test.go +++ b/server/config_internal_test.go @@ -309,12 +309,14 @@ func TestConfig_validateAuth(t *testing.T) { errorMesgEmpty, errorMesgEmpty, errorMesgEmpty, + errorMesgEmpty, }, Auth{ Enable: enable, ClientId: emptyString, ClientSecret: emptyString, AuthorizeURL: emptyString, + RedirectBaseURL: emptyString, TokenURL: emptyString, GroupEndpointURL: emptyString, LogoutURL: emptyString, @@ -334,6 +336,7 @@ func TestConfig_validateAuth(t *testing.T) { ClientSecret: validClientSecret, AuthorizeURL: validTestURL, TokenURL: validTestURL, + RedirectBaseURL: validTestURL, GroupEndpointURL: validTestURL, LogoutURL: validTestURL, Scopes: validStringSlice, @@ -354,6 +357,7 @@ func TestConfig_validateAuth(t *testing.T) { AuthorizeURL: validTestURL, TokenURL: invalidURL, GroupEndpointURL: invalidURL, + RedirectBaseURL: validTestURL, LogoutURL: invalidURL, Scopes: validStringSlice, SecretKey: validKey, @@ -372,6 +376,7 @@ func TestConfig_validateAuth(t *testing.T) { AuthorizeURL: validTestURL, TokenURL: validTestURL, GroupEndpointURL: validTestURL, + RedirectBaseURL: validTestURL, LogoutURL: validTestURL, Scopes: emptySlice, SecretKey: validKey, @@ -387,6 +392,7 @@ func TestConfig_validateAuth(t *testing.T) { ClientSecret: validClientSecret, AuthorizeURL: validTestURL, TokenURL: validTestURL, + RedirectBaseURL: validTestURL, GroupEndpointURL: validTestURL, LogoutURL: validTestURL, Scopes: validStringSlice, @@ -402,6 +408,7 @@ func TestConfig_validateAuth(t *testing.T) { ClientId: emptyString, ClientSecret: validString, AuthorizeURL: emptyString, + RedirectBaseURL: validTestURL, TokenURL: emptyString, GroupEndpointURL: invalidURL, LogoutURL: validTestURL, diff --git a/server/config_test.go b/server/config_test.go index ce336ba59..77490d451 100644 --- a/server/config_test.go +++ b/server/config_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/toml" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/toml" ) func Test_ValidateConfig(t *testing.T) { diff --git a/server/grpc.go b/server/grpc.go index f24823915..0fff11427 100644 --- a/server/grpc.go +++ b/server/grpc.go @@ -13,15 +13,15 @@ import ( "time" "github.com/improbable-eng/grpc-web/go/grpcweb" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/authn" - "github.com/molecula/featurebase/v2/authz" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/pql" - pb "github.com/molecula/featurebase/v2/proto" - vdsm_pb "github.com/molecula/featurebase/v2/proto/vdsm" - "github.com/molecula/featurebase/v2/sql" - "github.com/molecula/featurebase/v2/stats" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/authn" + "github.com/molecula/featurebase/v3/authz" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/pql" + pb "github.com/molecula/featurebase/v3/proto" + vdsm_pb "github.com/molecula/featurebase/v3/proto/vdsm" + "github.com/molecula/featurebase/v3/sql" + "github.com/molecula/featurebase/v3/stats" "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -30,6 +30,7 @@ import ( "google.golang.org/grpc/peer" "google.golang.org/grpc/reflection" "google.golang.org/grpc/status" + "vitess.io/vitess/go/vt/sqlparser" ) // GRPCHandler contains methods which handle the various gRPC requests. @@ -165,8 +166,8 @@ func isAllowed(requested []string, allowed []string) bool { // QuerySQL handles the SQL request and sends RowResponses to the stream. func (h *GRPCHandler) QuerySQL(req *pb.QuerySQLRequest, stream pb.Pilosa_QuerySQLServer) error { ctx := stream.Context() - uinfo := ctx.Value("userinfo") - if uinfo != nil { + uinfo, ok := ctx.Value("userinfo").(*authn.UserInfo) + if ok && uinfo != nil { // authz m := sql.NewMapper() parsed, err := m.MapSQL(req.Sql) @@ -174,13 +175,20 @@ func (h *GRPCHandler) QuerySQL(req *pb.QuerySQLRequest, stream pb.Pilosa_QuerySQ return errors.Wrap(err, "parsing SQL") } - allowed := h.perms.GetAuthorizedIndexList(uinfo.(*authn.UserInfo).Groups, authz.Read) - if !h.perms.IsAdmin(uinfo.(*authn.UserInfo).Groups) { + perm := authz.Read + switch parsed.Statement.(type) { + case *sqlparser.DDL: // currently only used for DropTable + perm = authz.Admin + } + + allowed := h.perms.GetAuthorizedIndexList(uinfo.Groups, perm) + if !h.perms.IsAdmin(uinfo.Groups) { if !isAllowed(parsed.Tables, allowed) { return status.Error(codes.PermissionDenied, "insufficient permissions to access requested tables") } ctx = context.WithValue(ctx, "indices", allowed) } + LogQuery(ctx, "QuerySQL", req, h.queryLogger) } start := time.Now() @@ -219,9 +227,29 @@ func (h *GRPCHandler) QuerySQL(req *pb.QuerySQLRequest, stream pb.Pilosa_QuerySQ func (h *GRPCHandler) QuerySQLUnary(ctx context.Context, req *pb.QuerySQLRequest) (*pb.TableResponse, error) { start := time.Now() uinfo := ctx.Value("userinfo") - if uinfo != nil && !h.perms.IsAdmin(uinfo.(*authn.UserInfo).Groups) { - ctx = context.WithValue(ctx, "indices", h.perms.GetAuthorizedIndexList(uinfo.(*authn.UserInfo).Groups, authz.Read)) + if uinfo != nil { + // authz + m := sql.NewMapper() + parsed, err := m.MapSQL(req.Sql) + if err != nil { + return nil, errors.Wrap(err, "parsing SQL") + } + + perm := authz.Read + switch parsed.Statement.(type) { + case *sqlparser.DDL: // currently only used for DropTable + perm = authz.Admin + } + + allowed := h.perms.GetAuthorizedIndexList(uinfo.(*authn.UserInfo).Groups, perm) + if !h.perms.IsAdmin(uinfo.(*authn.UserInfo).Groups) { + if !isAllowed(parsed.Tables, allowed) { + return nil, status.Error(codes.PermissionDenied, "insufficient permissions to access requested tables") + } + ctx = context.WithValue(ctx, "indices", allowed) + } } + results, err := h.execSQL(ctx, req.Sql) if err != nil { return nil, err @@ -272,6 +300,7 @@ func (h *GRPCHandler) QueryPQL(req *pb.QueryPQLRequest, stream pb.Pilosa_QueryPQ return status.Error(codes.PermissionDenied, "insufficient permissions to access requested indexes") } } + LogQuery(ctx, "QueryPQL", req, h.queryLogger) } t := time.Now() resp, err := h.api.Query(stream.Context(), &query) @@ -429,10 +458,10 @@ func (h *GRPCHandler) GetIndex(ctx context.Context, req *pb.GetIndexRequest) (*p // GetIndexes returns a list of all Indexes func (h *GRPCHandler) GetIndexes(ctx context.Context, req *pb.GetIndexesRequest) (*pb.GetIndexesResponse, error) { uinfo := ctx.Value("userinfo") - var pp *authn.UserInfo + var userInfo *authn.UserInfo if uinfo != nil { var ok bool - pp, ok = uinfo.(*authn.UserInfo) + userInfo, ok = uinfo.(*authn.UserInfo) if !ok { return nil, status.Error(codes.InvalidArgument, "malformed auth header") } @@ -442,17 +471,14 @@ func (h *GRPCHandler) GetIndexes(ctx context.Context, req *pb.GetIndexesRequest) return nil, errToStatusError(err) } - indexes := make([]*pb.Index, len(schema)) - i := 0 + indexes := make([]*pb.Index, 0) for _, index := range schema { - if pp != nil { - if p, err := h.perms.GetPermissions(pp, index.Name); err == nil && p.Satisfies(authz.Read) { - indexes[i] = &pb.Index{Name: index.Name} - i += 1 + if userInfo != nil { + if p, err := h.perms.GetPermissions(userInfo, index.Name); err == nil && p.Satisfies(authz.Read) { + indexes = append(indexes, &pb.Index{Name: index.Name}) } } else { - indexes[i] = &pb.Index{Name: index.Name} - i += 1 + indexes = append(indexes, &pb.Index{Name: index.Name}) } } return &pb.GetIndexesResponse{Indexes: indexes}, nil @@ -693,6 +719,8 @@ func (h *GRPCHandler) Inspect(req *pb.InspectRequest, stream pb.Pilosa_InspectSe h.logger.Infof("DEPRECATED: Inspect is deprecated, please use Extract() instead.") }) + LogQuery(stream.Context(), "Inspect", req, h.queryLogger) + index, err := h.api.Index(stream.Context(), req.Index) if err != nil { return errToStatusError(err) @@ -1561,16 +1589,17 @@ func NewGRPCServer(opts ...grpcServerOption) (*grpcServer, error) { if server.auth != nil { gopts = append(gopts, grpc.UnaryInterceptor( func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { - ctx, err := Valid(ctx, info.FullMethod, server.auth, req, server.queryLogger) + ctx, err := Valid(ctx, server.auth) if err != nil { return nil, err } + LogQuery(ctx, info.FullMethod, req, server.logger) return handler(ctx, req) }, )) gopts = append(gopts, grpc.StreamInterceptor( func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error { - ctx, err := Valid(ss.Context(), info.FullMethod, server.auth, srv, server.queryLogger) + ctx, err := Valid(ss.Context(), server.auth) if err != nil { return err } @@ -1597,6 +1626,29 @@ func NewGRPCServer(opts ...grpcServerOption) (*grpcServer, error) { return server, nil } +// LogQuery logs requests +func LogQuery(ctx context.Context, method string, req interface{}, logger logger.Logger) { + uinfo, ok := ctx.Value("userinfo").(*authn.UserInfo) + md, _ := metadata.FromIncomingContext(ctx) + p, ok := peer.FromContext(ctx) + ip := "" + if ok { + ip = p.Addr.String() + } + ua, ok := md["user-agent"] + if !ok { + ua = []string{""} + } + switch r := req.(type) { + case *pb.QueryPQLRequest: + logger.Infof("GRPC: %v, %v, %v, %v, %v, %s", ip, ua, method, uinfo.UserID, uinfo.UserName, r.Pql) + case *pb.QuerySQLRequest: + logger.Infof("GRPC: %v, %v, %v, %v, %v, %s", ip, ua, method, uinfo.UserID, uinfo.UserName, r.Sql) + default: + logger.Infof("GRPC: %v, %v, %v, %v, %v", ip, ua, method, uinfo.UserID, uinfo.UserName) + } +} + // wrappedStream wraps around the embedded grpc.ServerStream, and intercepts the RecvMsg and // SendMsg method call. type wrappedStream struct { @@ -1616,7 +1668,7 @@ func (w *wrappedStream) SendMsg(m interface{}) error { return w.ServerStream.SendMsg(m) } -func Valid(ctx context.Context, method string, auth *authn.Auth, req interface{}, logger logger.Logger) (context.Context, error) { +func Valid(ctx context.Context, auth *authn.Auth) (context.Context, error) { md, ok := metadata.FromIncomingContext(ctx) if !ok { return ctx, status.Errorf(codes.InvalidArgument, "missing metadata") @@ -1646,16 +1698,5 @@ func Valid(ctx context.Context, method string, auth *authn.Auth, req interface{} return ctx, status.Errorf(codes.Unauthenticated, err.Error()) } - p, ok := peer.FromContext(ctx) - ip := "" - if ok { - ip = p.Addr.String() - } - ua, ok := md["user-agent"] - if !ok { - ua = []string{""} - } - logger.Infof("GRPC: %v, %v, %v, %v, %v, %v", ip, ua, method, uinfo.UserID, uinfo.UserName, req) - return context.WithValue(ctx, "userinfo", uinfo), nil } diff --git a/server/grpc_test.go b/server/grpc_test.go index c2b993a96..376b44ff2 100644 --- a/server/grpc_test.go +++ b/server/grpc_test.go @@ -2,6 +2,7 @@ package server_test import ( + "bytes" "context" "encoding/hex" "fmt" @@ -15,15 +16,15 @@ import ( "time" "github.com/golang-jwt/jwt" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/authn" - "github.com/molecula/featurebase/v2/authz" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/pql" - pb "github.com/molecula/featurebase/v2/proto" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/sql" - "github.com/molecula/featurebase/v2/test" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/authn" + "github.com/molecula/featurebase/v3/authz" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/pql" + pb "github.com/molecula/featurebase/v3/proto" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/sql" + "github.com/molecula/featurebase/v3/test" "github.com/pkg/errors" "google.golang.org/grpc" "google.golang.org/grpc/codes" @@ -843,6 +844,8 @@ func TestQuerySQL(t *testing.T) { {"Table", "string"}, }, rows: []row{ + {[]columnResponse{"another_one"}}, + {[]columnResponse{"deletable_index"}}, {[]columnResponse{"delete_me"}}, {[]columnResponse{"grouper"}}, {[]columnResponse{"joiner"}}, @@ -881,6 +884,9 @@ func TestQuerySQL(t *testing.T) { {"Table", "string"}, }, rows: []row{ + {[]columnResponse{"another_one"}}, + {[]columnResponse{"deletable_index"}}, + {[]columnResponse{"grouper"}}, {[]columnResponse{"joiner"}}, }, @@ -1162,6 +1168,7 @@ admin: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe"` t.Fatal(err) } }) + t.Run("test-show-tables-unary-admin", func(t *testing.T) { response, err := gh.QuerySQLUnary(adminCtx, &pb.QuerySQLRequest{ Sql: "show tables", @@ -1190,6 +1197,55 @@ admin: "ac97c9e2-346b-42a2-b6da-18bcb61a32fe"` t.Fatal(err) } }) + + t.Run("test-drop-table-unary-read", func(t *testing.T) { + _, err := gh.QuerySQLUnary(readCtx, &pb.QuerySQLRequest{ + Sql: "drop table deletable_index", + }) + if err == nil { + t.Fatal("expected error but got nil") + } + }) + + t.Run("test-drop-table-unary-write", func(t *testing.T) { + _, err := gh.QuerySQLUnary(writeCtx, &pb.QuerySQLRequest{ + Sql: "drop table deletable_index", + }) + if err == nil { + t.Fatal("expected error but got nil") + } + }) + + t.Run("test-drop-table-unary-admin", func(t *testing.T) { + _, err := gh.QuerySQLUnary(adminCtx, &pb.QuerySQLRequest{ + Sql: "drop table deletable_index", + }) + if err != nil { + t.Fatalf("expected nil error but got %v", err) + } + }) + + t.Run("test-drop-table-stream-read", func(t *testing.T) { + mock := &mockPilosa_QuerySQLServer{ctx: readCtx} + err := gh.QuerySQL(&pb.QuerySQLRequest{Sql: "drop table another_one"}, mock) + if err == nil { + t.Fatal("expected error but got nil") + } + }) + t.Run("test-drop-table-stream-write", func(t *testing.T) { + mock := &mockPilosa_QuerySQLServer{ctx: writeCtx} + err := gh.QuerySQL(&pb.QuerySQLRequest{Sql: "drop table another_one"}, mock) + if err == nil { + t.Fatal("expected error but got nil") + } + }) + t.Run("test-drop-table-stream-admin", func(t *testing.T) { + mock := &mockPilosa_QuerySQLServer{ctx: adminCtx} + err := gh.QuerySQL(&pb.QuerySQLRequest{Sql: "drop table another_one"}, mock) + if err != nil { + t.Fatalf("expected nil error but got %v", err) + } + }) } func TestCRUDIndexes(t *testing.T) { @@ -1372,6 +1428,47 @@ func TestCRUDIndexes(t *testing.T) { }) } +func TestLogQuery(t *testing.T) { + method := "test!" + uinfo := authn.UserInfo{ + UserID: "ID", + UserName: "name", + } + ctx := context.WithValue(context.Background(), "userinfo", &uinfo) + + cases := []struct { + name string + req interface{} + expected string + }{ + { + name: "nonQueryReq", + req: "nope", + expected: fmt.Sprintf("GRPC: %v, %v, %v, %v, %v\n", "", []string{}, "test!", uinfo.UserID, uinfo.UserName), + }, + { + name: "QuerySQLReq", + req: &pb.QuerySQLRequest{Sql: "show fields from table"}, + expected: fmt.Sprintf("GRPC: %v, %v, %v, %v, %v, %v\n", "", []string{}, "test!", uinfo.UserID, uinfo.UserName, "show fields from table"), + }, + { + name: "QueryPQLReq", + req: &pb.QueryPQLRequest{Pql: "Count(All())"}, + expected: fmt.Sprintf("GRPC: %v, %v, %v, %v, %v, %v\n", "", []string{}, "test!", uinfo.UserID, uinfo.UserName, "Count(All())"), + }, + } + for _, test := range cases { + t.Run(test.name, func(t *testing.T) { + buf := new(bytes.Buffer) + l := logger.NewStandardLogger(buf) + server.LogQuery(ctx, method, test.req, l) + if !strings.HasSuffix(buf.String(), test.expected) { + t.Errorf("expected '%v', got '%v'", test.expected, buf.String()) + } + }) + } +} + func setUpTestQuerySQLUnary(ctx context.Context, t *testing.T) (gh *server.GRPCHandler, tearDownFunc func()) { t.Helper() @@ -1506,6 +1603,9 @@ func setUpTestQuerySQLUnary(ctx context.Context, t *testing.T) (gh *server.GRPCH // delete_me m.MustCreateIndex(t, "delete_me", pilosa.IndexOptions{TrackExistence: true}) + m.MustCreateIndex(t, "another_one", pilosa.IndexOptions{TrackExistence: true}) + m.MustCreateIndex(t, "deletable_index", pilosa.IndexOptions{TrackExistence: true}) + return gh, func() { if err := m.API.DeleteIndex(ctx, joiner.Name()); err != nil { panic(err) diff --git a/server/handler_test.go b/server/handler_test.go index 1e1105ff4..48dddde78 100644 --- a/server/handler_test.go +++ b/server/handler_test.go @@ -18,13 +18,13 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/encoding/proto" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/encoding/proto" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" ) func TestHandler_PostSchemaCluster(t *testing.T) { diff --git a/server/pg.go b/server/pg.go index 42b95d987..87b1f8fa8 100644 --- a/server/pg.go +++ b/server/pg.go @@ -12,14 +12,14 @@ import ( "strings" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/pg" - "github.com/molecula/featurebase/v2/sql2" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/pg" + "github.com/molecula/featurebase/v3/sql2" - //"github.com/molecula/featurebase/v2/pg" - "github.com/molecula/featurebase/v2/pql" - pb "github.com/molecula/featurebase/v2/proto" + //"github.com/molecula/featurebase/v3/pg" + "github.com/molecula/featurebase/v3/pql" + pb "github.com/molecula/featurebase/v3/proto" "github.com/pkg/errors" "golang.org/x/sync/errgroup" diff --git a/server/pg_internal_test.go b/server/pg_internal_test.go index 83ed1780f..5c870b501 100644 --- a/server/pg_internal_test.go +++ b/server/pg_internal_test.go @@ -4,8 +4,8 @@ package server import ( "testing" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pg" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pg" ) // pg_internal_test.go tests unexported methods from server/pg.go diff --git a/server/pg_test.go b/server/pg_test.go index 8cfb21035..7250c6f7e 100644 --- a/server/pg_test.go +++ b/server/pg_test.go @@ -8,12 +8,12 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/pg" - "github.com/molecula/featurebase/v2/pg/pgtest" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/pg" + "github.com/molecula/featurebase/v3/pg/pgtest" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" ) func TestPostgresHandler(t *testing.T) { diff --git a/server/server.go b/server/server.go index 781a1a216..8212f6816 100644 --- a/server/server.go +++ b/server/server.go @@ -28,23 +28,23 @@ import ( "golang.org/x/sync/errgroup" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/authn" - "github.com/molecula/featurebase/v2/authz" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/encoding/proto" - petcd "github.com/molecula/featurebase/v2/etcd" - "github.com/molecula/featurebase/v2/gcnotify" - "github.com/molecula/featurebase/v2/gopsutil" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/logger" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/prometheus" - "github.com/molecula/featurebase/v2/statik" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/statsd" - "github.com/molecula/featurebase/v2/syswrap" - "github.com/molecula/featurebase/v2/testhook" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/authn" + "github.com/molecula/featurebase/v3/authz" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/encoding/proto" + petcd "github.com/molecula/featurebase/v3/etcd" + "github.com/molecula/featurebase/v3/gcnotify" + "github.com/molecula/featurebase/v3/gopsutil" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/logger" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/prometheus" + "github.com/molecula/featurebase/v3/statik" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/statsd" + "github.com/molecula/featurebase/v3/syswrap" + "github.com/molecula/featurebase/v3/testhook" "github.com/pelletier/go-toml" "github.com/pkg/errors" ) @@ -538,7 +538,7 @@ func (m *Command) SetupServer() error { } ac := m.Config.Auth - m.auth, err = authn.NewAuth(m.logger, m.listenURI.String(), ac.Scopes, ac.AuthorizeURL, ac.TokenURL, ac.GroupEndpointURL, ac.LogoutURL, ac.ClientId, ac.ClientSecret, ac.SecretKey) + m.auth, err = authn.NewAuth(m.logger, ac.RedirectBaseURL, ac.Scopes, ac.AuthorizeURL, ac.TokenURL, ac.GroupEndpointURL, ac.LogoutURL, ac.ClientId, ac.ClientSecret, ac.SecretKey) if err != nil { return errors.Wrap(err, "instantiating authN object") } diff --git a/server/server_test.go b/server/server_test.go index 551781ffb..3dfd92728 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -17,14 +17,14 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/testhook" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/testhook" "github.com/pkg/errors" "github.com/stretchr/testify/require" "golang.org/x/sync/errgroup" diff --git a/server/sql.go b/server/sql.go index b936f89c6..6cf0a457a 100644 --- a/server/sql.go +++ b/server/sql.go @@ -4,10 +4,10 @@ package server import ( "context" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/logger" - pb "github.com/molecula/featurebase/v2/proto" - "github.com/molecula/featurebase/v2/sql" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/logger" + pb "github.com/molecula/featurebase/v3/proto" + "github.com/molecula/featurebase/v3/sql" "github.com/pkg/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/server/tlsconfig.go b/server/tlsconfig.go index 82bed6693..4976fa6e5 100644 --- a/server/tlsconfig.go +++ b/server/tlsconfig.go @@ -42,7 +42,7 @@ import ( "sync" "syscall" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" "github.com/pkg/errors" ) diff --git a/server/trial.go b/server/trial.go index 057a786d1..eddc20b16 100644 --- a/server/trial.go +++ b/server/trial.go @@ -12,7 +12,7 @@ import ( "time" "github.com/beevik/ntp" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" ) // handleTrialDeadline checks to see if this is a trial version of Molecula that expires at some point. diff --git a/server_internal_test.go b/server_internal_test.go index 763f2dc6a..9859e950d 100644 --- a/server_internal_test.go +++ b/server_internal_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/storage" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/storage" + "github.com/molecula/featurebase/v3/testhook" ) // Ensure the file handle count is working diff --git a/shardwidth/helper_test.go b/shardwidth/helper_test.go index 8966d5aad..458edb678 100644 --- a/shardwidth/helper_test.go +++ b/shardwidth/helper_test.go @@ -5,7 +5,7 @@ import ( "math/rand" "testing" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/shardwidth" ) type nextShardTestCase struct { diff --git a/snapshotqueue.go b/snapshotqueue.go index a33f90bce..ef0bda24c 100644 --- a/snapshotqueue.go +++ b/snapshotqueue.go @@ -11,8 +11,8 @@ import ( "sync/atomic" "time" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/testhook" "github.com/pkg/errors" ) diff --git a/sql/ddl.go b/sql/ddl.go index 9390e3c06..70d553304 100644 --- a/sql/ddl.go +++ b/sql/ddl.go @@ -5,8 +5,8 @@ import ( "context" "fmt" - "github.com/molecula/featurebase/v2" - pproto "github.com/molecula/featurebase/v2/proto" + "github.com/molecula/featurebase/v3" + pproto "github.com/molecula/featurebase/v3/proto" "github.com/pkg/errors" "vitess.io/vitess/go/vt/sqlparser" ) diff --git a/sql/extract.go b/sql/extract.go index 0165f5f40..73a7e795e 100644 --- a/sql/extract.go +++ b/sql/extract.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pql" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pql" "github.com/pkg/errors" "vitess.io/vitess/go/vt/sqlparser" ) diff --git a/sql/handler_test.go b/sql/handler_test.go index 4f2e263bb..6eaba476f 100644 --- a/sql/handler_test.go +++ b/sql/handler_test.go @@ -5,8 +5,8 @@ import ( "context" "testing" - "github.com/molecula/featurebase/v2/sql" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3/sql" + "github.com/molecula/featurebase/v3/test" ) func TestHandler(t *testing.T) { diff --git a/sql/mapper.go b/sql/mapper.go index 4e271bdbe..a8cec076b 100644 --- a/sql/mapper.go +++ b/sql/mapper.go @@ -4,7 +4,7 @@ package sql import ( "strings" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" "github.com/pkg/errors" "vitess.io/vitess/go/vt/sqlparser" ) diff --git a/sql/model.go b/sql/model.go index 5d87aa47a..2019814a9 100644 --- a/sql/model.go +++ b/sql/model.go @@ -4,7 +4,7 @@ package sql import ( "fmt" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" "github.com/pkg/errors" ) diff --git a/sql/reduce.go b/sql/reduce.go index a4cf4211d..8de56c1f0 100644 --- a/sql/reduce.go +++ b/sql/reduce.go @@ -4,9 +4,9 @@ package sql import ( "sort" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pql" - pproto "github.com/molecula/featurebase/v2/proto" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pql" + pproto "github.com/molecula/featurebase/v3/proto" "github.com/pkg/errors" ) diff --git a/sql/reduce_test.go b/sql/reduce_test.go index dcddba726..4efafdfa1 100644 --- a/sql/reduce_test.go +++ b/sql/reduce_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - pproto "github.com/molecula/featurebase/v2/proto" + pproto "github.com/molecula/featurebase/v3/proto" "github.com/pkg/errors" ) diff --git a/sql/select.go b/sql/select.go index 07385d80d..3297ee0fc 100644 --- a/sql/select.go +++ b/sql/select.go @@ -6,9 +6,9 @@ import ( "fmt" "strings" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pql" - pproto "github.com/molecula/featurebase/v2/proto" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pql" + pproto "github.com/molecula/featurebase/v3/proto" "github.com/pkg/errors" "vitess.io/vitess/go/vt/sqlparser" ) diff --git a/sql/show.go b/sql/show.go index 186d51923..4ceb829e5 100644 --- a/sql/show.go +++ b/sql/show.go @@ -5,8 +5,8 @@ import ( "context" "fmt" - pilosa "github.com/molecula/featurebase/v2" - pproto "github.com/molecula/featurebase/v2/proto" + pilosa "github.com/molecula/featurebase/v3" + pproto "github.com/molecula/featurebase/v3/proto" "github.com/pkg/errors" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/sql2/ast_test.go b/sql2/ast_test.go index 7523fe77d..c625393ed 100644 --- a/sql2/ast_test.go +++ b/sql2/ast_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/go-test/deep" - sql "github.com/molecula/featurebase/v2/sql2" + sql "github.com/molecula/featurebase/v3/sql2" ) func TestExprString(t *testing.T) { diff --git a/sql2/parser_test.go b/sql2/parser_test.go index 2a7be9f90..04745c9a6 100644 --- a/sql2/parser_test.go +++ b/sql2/parser_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/go-test/deep" - sql "github.com/molecula/featurebase/v2/sql2" + sql "github.com/molecula/featurebase/v3/sql2" ) func TestParser_ParseStatement(t *testing.T) { diff --git a/sql2/scanner_test.go b/sql2/scanner_test.go index 63763195d..7b9cd5436 100644 --- a/sql2/scanner_test.go +++ b/sql2/scanner_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - sql "github.com/molecula/featurebase/v2/sql2" + sql "github.com/molecula/featurebase/v3/sql2" ) func TestScanner_Scan(t *testing.T) { diff --git a/sql2/token_test.go b/sql2/token_test.go index 03e583600..773f347b6 100644 --- a/sql2/token_test.go +++ b/sql2/token_test.go @@ -4,7 +4,7 @@ package sql2_test import ( "testing" - sql "github.com/molecula/featurebase/v2/sql2" + sql "github.com/molecula/featurebase/v3/sql2" ) func TestPos_String(t *testing.T) { diff --git a/statik/filesystem.go b/statik/filesystem.go index 333a92c0a..4f0160db1 100644 --- a/statik/filesystem.go +++ b/statik/filesystem.go @@ -9,7 +9,7 @@ package statik import ( "net/http" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" "github.com/rakyll/statik/fs" ) diff --git a/stats/stats.go b/stats/stats.go index 7ec018479..ba634de72 100644 --- a/stats/stats.go +++ b/stats/stats.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" ) // Expvar global expvar map. diff --git a/stats/stats_test.go b/stats/stats_test.go index 11e99c5ef..b2867d184 100644 --- a/stats/stats_test.go +++ b/stats/stats_test.go @@ -9,11 +9,11 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/test" ) // TestMultiStatClient_Expvar run the multistat client with exp var diff --git a/statsd/statsd.go b/statsd/statsd.go index a21ada41d..e9975f79f 100644 --- a/statsd/statsd.go +++ b/statsd/statsd.go @@ -6,8 +6,8 @@ import ( "time" "github.com/DataDog/datadog-go/statsd" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/stats" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/stats" ) // StatsD protocol wrapper using the DataDog library that added Tags to the StatsD protocol diff --git a/statsd/statsd_test.go b/statsd/statsd_test.go index c466798bb..8c8b8e43a 100644 --- a/statsd/statsd_test.go +++ b/statsd/statsd_test.go @@ -6,8 +6,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/statsd" - _ "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3/statsd" + _ "github.com/molecula/featurebase/v3/test" ) func TestStatsClient_WithTags(t *testing.T) { diff --git a/stattx.go b/stattx.go index 16b4d658a..8b34ec582 100644 --- a/stattx.go +++ b/stattx.go @@ -9,10 +9,10 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/debugstats" - "github.com/molecula/featurebase/v2/roaring" - txkey "github.com/molecula/featurebase/v2/short_txkey" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/debugstats" + "github.com/molecula/featurebase/v3/roaring" + txkey "github.com/molecula/featurebase/v3/short_txkey" + "github.com/molecula/featurebase/v3/vprint" ) // statTx is useful to profile on a diff --git a/test/cluster.go b/test/cluster.go index 58c27a4d6..5aea1147f 100644 --- a/test/cluster.go +++ b/test/cluster.go @@ -10,13 +10,13 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/api/client" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/proto" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/storage" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/api/client" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/proto" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/storage" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/test/disco.go b/test/disco.go index 847d78258..abd77e59c 100644 --- a/test/disco.go +++ b/test/disco.go @@ -8,9 +8,9 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/etcd" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/etcd" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/testhook" "github.com/pkg/errors" ) @@ -38,7 +38,7 @@ func (ports *Ports) Close() error { return err3 } -// listenerPortURL builds a TCP listener and corresponding http://localhost:%d +// listenerWithURL builds a TCP listener and corresponding http://localhost:%d // URL, and returns those. func listenerWithURL() (listener *net.TCPListener, url string, err error) { l, err := net.Listen("tcp", ":0") diff --git a/test/field.go b/test/field.go index 8554f88df..d38e4ef17 100644 --- a/test/field.go +++ b/test/field.go @@ -2,7 +2,7 @@ package test import ( - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" ) // Field represents a test wrapper for pilosa.Field. diff --git a/test/holder.go b/test/holder.go index 8418d95a5..ec981ddf8 100644 --- a/test/holder.go +++ b/test/holder.go @@ -6,10 +6,10 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/vprint" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/vprint" "github.com/pkg/errors" ) diff --git a/test/index.go b/test/index.go index 7b3edf42f..6e4ec5255 100644 --- a/test/index.go +++ b/test/index.go @@ -5,8 +5,8 @@ import ( "context" "testing" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/testhook" ) // Index represents a test wrapper for pilosa.Index. diff --git a/test/pilosa.go b/test/pilosa.go index 56747309e..83041998c 100644 --- a/test/pilosa.go +++ b/test/pilosa.go @@ -13,12 +13,12 @@ import ( "testing" "time" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/encoding/proto" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/testhook" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/encoding/proto" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/testhook" ) //////////////////////////////////////////////////////////////////////////////////// diff --git a/test/pilosa_test.go b/test/pilosa_test.go index 4feea2d92..c27a15c95 100644 --- a/test/pilosa_test.go +++ b/test/pilosa_test.go @@ -8,8 +8,8 @@ import ( "strings" "testing" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/test" ) func TestNewCluster(t *testing.T) { diff --git a/test/transaction.go b/test/transaction.go index 3ca524db4..1832f866f 100644 --- a/test/transaction.go +++ b/test/transaction.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" + "github.com/molecula/featurebase/v3" ) const deadlineSkew = time.Second diff --git a/testhook/auditor_test.go b/testhook/auditor_test.go index f6dad6157..9bc1b8f06 100644 --- a/testhook/auditor_test.go +++ b/testhook/auditor_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/molecula/featurebase/v2/testhook" + "github.com/molecula/featurebase/v3/testhook" ) func TestAuditor_CatchError(t *testing.T) { diff --git a/topology/node.go b/topology/node.go index 73b424413..e5c33df5f 100644 --- a/topology/node.go +++ b/topology/node.go @@ -4,8 +4,8 @@ package topology import ( "fmt" - "github.com/molecula/featurebase/v2/disco" - "github.com/molecula/featurebase/v2/net" + "github.com/molecula/featurebase/v3/disco" + "github.com/molecula/featurebase/v3/net" ) // Node represents a node in the cluster. diff --git a/topology/snapshot.go b/topology/snapshot.go index 1c6c01ff6..218ab3a4e 100644 --- a/topology/snapshot.go +++ b/topology/snapshot.go @@ -5,8 +5,8 @@ import ( "encoding/binary" "hash/fnv" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/shardwidth" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/shardwidth" ) const ( diff --git a/tracing/opentracing/opentracing.go b/tracing/opentracing/opentracing.go index b6ed1034c..26a13e923 100644 --- a/tracing/opentracing/opentracing.go +++ b/tracing/opentracing/opentracing.go @@ -5,8 +5,8 @@ import ( "context" "net/http" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/tracing" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/tracing" "github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go/ext" ) diff --git a/transaction.go b/transaction.go index ca09f81f8..9c912f0b1 100644 --- a/transaction.go +++ b/transaction.go @@ -8,7 +8,7 @@ import ( "sync" "time" - "github.com/molecula/featurebase/v2/logger" + "github.com/molecula/featurebase/v3/logger" "github.com/pkg/errors" ) diff --git a/transaction_test.go b/transaction_test.go index f9ed5884b..933a5013a 100644 --- a/transaction_test.go +++ b/transaction_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/logger" - "github.com/molecula/featurebase/v2/test" + "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/logger" + "github.com/molecula/featurebase/v3/test" ) // TestTransactionManager currently uses an in memory transaction diff --git a/translate.go b/translate.go index be1c47306..cc36ebbe2 100644 --- a/translate.go +++ b/translate.go @@ -10,8 +10,8 @@ import ( "sort" "sync" - "github.com/molecula/featurebase/v2/ingest" - "github.com/molecula/featurebase/v2/topology" + "github.com/molecula/featurebase/v3/ingest" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" ) diff --git a/translator_test.go b/translator_test.go index b9b4a08ff..38cc47c51 100644 --- a/translator_test.go +++ b/translator_test.go @@ -11,13 +11,13 @@ import ( "time" "github.com/google/go-cmp/cmp" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/boltdb" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/mock" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/test" - "github.com/molecula/featurebase/v2/topology" + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/boltdb" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/mock" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/test" + "github.com/molecula/featurebase/v3/topology" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/tx.go b/tx.go index e8628c0e5..65a3e3c3f 100644 --- a/tx.go +++ b/tx.go @@ -2,9 +2,9 @@ package pilosa import ( - "github.com/molecula/featurebase/v2/roaring" - txkey "github.com/molecula/featurebase/v2/short_txkey" - //txkey "github.com/molecula/featurebase/v2/txkey" + "github.com/molecula/featurebase/v3/roaring" + txkey "github.com/molecula/featurebase/v3/short_txkey" + //txkey "github.com/molecula/featurebase/v3/txkey" ) // writable initializes Tx that update, use !writable for read-only. diff --git a/tx_internal_test.go b/tx_internal_test.go index 8ffa2bd45..1ab4140c1 100644 --- a/tx_internal_test.go +++ b/tx_internal_test.go @@ -6,7 +6,7 @@ import ( "sync" "testing" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/roaring" ) const countRangeMaxN = 8192 diff --git a/tx_test.go b/tx_test.go index f82a3f321..6f1815c8e 100644 --- a/tx_test.go +++ b/tx_test.go @@ -7,12 +7,12 @@ import ( "strings" "testing" - pilosa "github.com/molecula/featurebase/v2" - "github.com/molecula/featurebase/v2/http" - "github.com/molecula/featurebase/v2/server" - "github.com/molecula/featurebase/v2/storage" - "github.com/molecula/featurebase/v2/test" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + pilosa "github.com/molecula/featurebase/v3" + "github.com/molecula/featurebase/v3/http" + "github.com/molecula/featurebase/v3/server" + "github.com/molecula/featurebase/v3/storage" + "github.com/molecula/featurebase/v3/test" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck ) func queryIRABit(m0api *pilosa.API, acctOwnerID uint64, iraField string, iraRowID uint64, index string) (bit bool) { diff --git a/txfactory.go b/txfactory.go index 12fa12981..c16208532 100644 --- a/txfactory.go +++ b/txfactory.go @@ -10,8 +10,8 @@ import ( "strings" "sync" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/vprint" "github.com/pkg/errors" ) diff --git a/util.go b/util.go index 7b81e9363..ad7397688 100644 --- a/util.go +++ b/util.go @@ -9,7 +9,7 @@ import ( "syscall" "time" - "github.com/molecula/featurebase/v2/roaring" + "github.com/molecula/featurebase/v3/roaring" "github.com/pkg/errors" ) diff --git a/utils_internal_test.go b/utils_internal_test.go index 30f675134..072fd5b1c 100644 --- a/utils_internal_test.go +++ b/utils_internal_test.go @@ -6,9 +6,9 @@ import ( "testing" "time" - pnet "github.com/molecula/featurebase/v2/net" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/topology" + pnet "github.com/molecula/featurebase/v3/net" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/topology" ) // utilities used by tests diff --git a/version.go b/version.go index 4aa0bd514..3383b8809 100644 --- a/version.go +++ b/version.go @@ -22,7 +22,7 @@ func VersionInfo(rename bool) string { if Version != "" { suffix = " " + Version } else { - suffix = " v2.x" + suffix = " v3.x" } buildTime := BuildTime if buildTime != "" { diff --git a/view.go b/view.go index 43eed3c34..d5e408810 100644 --- a/view.go +++ b/view.go @@ -13,11 +13,11 @@ import ( "sync/atomic" "time" - "github.com/molecula/featurebase/v2/pql" - "github.com/molecula/featurebase/v2/roaring" - "github.com/molecula/featurebase/v2/stats" - "github.com/molecula/featurebase/v2/testhook" - "github.com/molecula/featurebase/v2/vprint" + "github.com/molecula/featurebase/v3/pql" + "github.com/molecula/featurebase/v3/roaring" + "github.com/molecula/featurebase/v3/stats" + "github.com/molecula/featurebase/v3/testhook" + "github.com/molecula/featurebase/v3/vprint" "github.com/pkg/errors" "golang.org/x/sync/errgroup" ) diff --git a/view_internal_test.go b/view_internal_test.go index 98afe9487..b5a52170e 100644 --- a/view_internal_test.go +++ b/view_internal_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/molecula/featurebase/v2/testhook" - . "github.com/molecula/featurebase/v2/vprint" // nolint:staticcheck + "github.com/molecula/featurebase/v3/testhook" + . "github.com/molecula/featurebase/v3/vprint" // nolint:staticcheck "golang.org/x/sync/errgroup" )