@cryptotaxi247 / kubo / commits / 5a3e56732

Do not put migrations under their own root

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.

gammazero committed Jan 11, 2021 at 20:06 UTC 5a3e567321401851e66afb42e85c063feaa6dfb9
3 files changed +23 -9
repo/fsrepo/migrations/fetch_test.go
+2 -2
@@ -40,7 +40,7 @@ func TestHttpFetch(t *testing.T) {
40
41 // Check bad URL
42 url = gatewayURL + path.Join(ipfsDistPath, distFSRM, "no_such_file")
43 - rc, err = httpFetch(ctx, url)
43 + _, err = httpFetch(ctx, url)
44 if err == nil || !strings.Contains(err.Error(), "404") {
45 t.Fatal("expected error 404")
46 }
@@ -81,7 +81,7 @@ func TestIpfsFetch(t *testing.T) {
81
82 // Check bad URL
83 url = path.Join(ipfsDistPath, distFSRM, "no_such_file")
84 - rc, err = ipfsFetch(ctx, url)
84 + _, err = ipfsFetch(ctx, url)
85 if err == nil || !strings.Contains(err.Error(), "no link") {
86 t.Fatal("expected 'no link' error, got:", err)
87 }
repo/fsrepo/migrations/migrations.go
+2 -2
@@ -14,8 +14,8 @@ import (
14 )
15
16 const (
17 - // Migrations distribution
18 - distMigsRoot = "go-ipfs-repo-migrations"
17 + // Migrations subdirectory in distribution. Empty for root (no subdir).
18 + distMigsRoot = ""
19 distFSRM = "fs-repo-migrations"
20 )
21
repo/fsrepo/migrations/migrations_test.go
+19 -5
@@ -3,8 +3,10 @@ package migrations
3 import (
4 "context"
5 "io/ioutil"
6 + "net/http"
7 "os"
8 "path"
9 + "strings"
10 "testing"
11 )
12
@@ -22,6 +24,9 @@ func TestFindMigrations(t *testing.T) {
24 if err != nil {
25 t.Fatal(err)
26 }
27 + if len(migs) != 5 {
28 + t.Fatal("expected 5 migrations")
29 + }
30 if len(bins) != 0 {
31 t.Fatal("should not have found migrations")
32 }
@@ -57,7 +62,16 @@ func TestFindMigrations(t *testing.T) {
62 }
63
64 func TestFetchMigrations(t *testing.T) {
60 - t.Skip("skip - migrations not available on distribution site yet")
65 + ctx, cancel := context.WithCancel(context.Background())
66 + defer cancel()
67 +
68 + _, err := LatestDistVersion(ctx, "ipfs-1-to-2")
69 + if err != nil {
70 + if strings.Contains(err.Error(), http.StatusText(http.StatusNotFound)) {
71 + t.Skip("skip - migrations not yet available on distribution site")
72 + }
73 + t.Fatal(err)
74 + }
75
76 tmpDir, err := ioutil.TempDir("", "migratetest")
77 if err != nil {
@@ -65,9 +79,6 @@ func TestFetchMigrations(t *testing.T) {
79 }
80 defer os.RemoveAll(tmpDir)
81
68 - ctx, cancel := context.WithCancel(context.Background())
69 - defer cancel()
70 -
82 needed := []string{"ipfs-1-to-2", "ipfs-2-to-3"}
83 fetched, err := fetchMigrations(ctx, needed, tmpDir)
84 if err != nil {
@@ -89,5 +100,8 @@ func createFakeBin(from, to int, tmpDir string) {
100 panic(err)
101 }
102 emptyFile.Close()
92 - os.Chmod(migPath, 0755)
103 + err = os.Chmod(migPath, 0755)
104 + if err != nil {
105 + panic(err)
106 + }
107 }