Skip to content

Commit

Permalink
Fix schema version to be relative to current path (cadence-workflow#534)
Browse files Browse the repository at this point in the history
  • Loading branch information
madhuravi authored Jan 30, 2018
1 parent 99f4899 commit c0b4358
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
6 changes: 2 additions & 4 deletions cmd/server/cadence.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package main
import (
"log"
"os"
"path"
"strings"

"github.com/uber/cadence/common/service/config"
Expand Down Expand Up @@ -54,12 +53,11 @@ func startHandler(c *cli.Context) {
log.Printf("config=\n%v\n", cfg.String())

cassCfg := cfg.Cassandra
dir, err := os.Getwd() // dir = /Users/madhuravi/Uber/gocode/src/github.com/uber/cadence
dir, err := os.Getwd()
if err != nil {
log.Fatal("Unable to get current directory")
}
root := path.Dir(path.Dir(path.Dir(dir))) // root = /Users/madhuravi/Uber/gocode/src
if err := cassandra.VerifyCompatibleVersion(cassCfg, root); err != nil {
if err := cassandra.VerifyCompatibleVersion(cassCfg, dir); err != nil {
log.Fatalf("Incompatible versions", err)
}
for _, svc := range getServices(c) {
Expand Down
7 changes: 3 additions & 4 deletions tools/cassandra/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@ func getExpectedVersion(dir string) (string, error) {
// In most cases, the versions should match. However if after a schema upgrade there is a code
// rollback, the code version (expected version) would fall lower than the actual version in
// cassandra.
func VerifyCompatibleVersion(cfg config.Cassandra, rootFile string) error {
projRoot := "github.com/uber/cadence/schema"
schemaPath := path.Join(rootFile, projRoot+"/cadence/versioned")
func VerifyCompatibleVersion(cfg config.Cassandra, rootPath string) error {
schemaPath := path.Join(rootPath, "schema/cadence/versioned")
if err := checkCompatibleVersion(cfg, cfg.Keyspace, schemaPath); err != nil {
return err
}
schemaPath = path.Join(rootFile, projRoot+"/visibility/versioned")
schemaPath = path.Join(rootPath, "schema/visibility/versioned")
return checkCompatibleVersion(cfg, cfg.VisibilityKeyspace, schemaPath)
}

Expand Down
2 changes: 1 addition & 1 deletion tools/cassandra/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (s *VersionTestSuite) TestVerifyCompatibleVersion() {
Keyspace: keyspace,
VisibilityKeyspace: visKeyspace,
}
s.NoError(VerifyCompatibleVersion(cfg, path.Dir(path.Dir(path.Dir(root)))))
s.NoError(VerifyCompatibleVersion(cfg, root))
}

func (s *VersionTestSuite) TestCheckCompatibleVersion() {
Expand Down

0 comments on commit c0b4358

Please sign in to comment.