Skip to content

Commit

Permalink
Do not put migrations under their own root
Browse files Browse the repository at this point in the history
Since the migrations are not displayed on the dirtributions, there is not need to organize them under their own root to reduce visual clutter.  Having each migration follow the same path as all other distributions makes each easier to find in the absence of a link displayed on the distributions web page.  It also avoids complicating the distribution deployment scripts and allows each migration distribution to be treated the same as any other distribution.
  • Loading branch information
gammazero committed Jan 12, 2021
1 parent dbb497b commit 51d4d82
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions repo/fsrepo/migrations/fetch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestHttpFetch(t *testing.T) {

// Check bad URL
url = gatewayURL + path.Join(ipfsDistPath, distFSRM, "no_such_file")
rc, err = httpFetch(ctx, url)
_, err = httpFetch(ctx, url)
if err == nil || !strings.Contains(err.Error(), "404") {
t.Fatal("expected error 404")
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestIpfsFetch(t *testing.T) {

// Check bad URL
url = path.Join(ipfsDistPath, distFSRM, "no_such_file")
rc, err = ipfsFetch(ctx, url)
_, err = ipfsFetch(ctx, url)
if err == nil || !strings.Contains(err.Error(), "no link") {
t.Fatal("expected 'no link' error, got:", err)
}
Expand Down
4 changes: 2 additions & 2 deletions repo/fsrepo/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
)

const (
// Migrations distribution
distMigsRoot = "go-ipfs-repo-migrations"
// Migrations subdirectory in distribution. Empty for root (no subdir).
distMigsRoot = ""
distFSRM = "fs-repo-migrations"
)

Expand Down
24 changes: 19 additions & 5 deletions repo/fsrepo/migrations/migrations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package migrations
import (
"context"
"io/ioutil"
"net/http"
"os"
"path"
"strings"
"testing"
)

Expand All @@ -22,6 +24,9 @@ func TestFindMigrations(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if len(migs) != 5 {
t.Fatal("expected 5 migrations")
}
if len(bins) != 0 {
t.Fatal("should not have found migrations")
}
Expand Down Expand Up @@ -57,17 +62,23 @@ func TestFindMigrations(t *testing.T) {
}

func TestFetchMigrations(t *testing.T) {
t.Skip("skip - migrations not available on distribution site yet")
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

_, err := LatestDistVersion(ctx, "ipfs-1-to-2")
if err != nil {
if strings.Contains(err.Error(), http.StatusText(http.StatusNotFound)) {
t.Skip("skip - migrations not yet available on distribution site")
}
t.Fatal(err)
}

tmpDir, err := ioutil.TempDir("", "migratetest")
if err != nil {
panic(err)
}
defer os.RemoveAll(tmpDir)

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

needed := []string{"ipfs-1-to-2", "ipfs-2-to-3"}
fetched, err := fetchMigrations(ctx, needed, tmpDir)
if err != nil {
Expand All @@ -89,5 +100,8 @@ func createFakeBin(from, to int, tmpDir string) {
panic(err)
}
emptyFile.Close()
os.Chmod(migPath, 0755)
err = os.Chmod(migPath, 0755)
if err != nil {
panic(err)
}
}

0 comments on commit 51d4d82

Please sign in to comment.