(t *testing.T)
| 24 | ) |
| 25 | |
| 26 | func TestAutomaticConfigUpgrade(t *testing.T) { |
| 27 | if base.UnitTestUrlIsWalrus() { |
| 28 | t.Skip("CBS required") |
| 29 | } |
| 30 | |
| 31 | ctx := base.TestCtx(t) |
| 32 | tb := base.GetTestBucket(t) |
| 33 | defer tb.Close(ctx) |
| 34 | |
| 35 | config := fmt.Sprintf(`{ |
| 36 | "server_tls_skip_verify": %t, |
| 37 | "interface": ":4444", |
| 38 | "adminInterface": ":4445", |
| 39 | "databases": { |
| 40 | "db": { |
| 41 | "server": "%s", |
| 42 | "username": "%s", |
| 43 | "password": "%s", |
| 44 | "bucket": "%s" |
| 45 | } |
| 46 | } |
| 47 | }`, |
| 48 | base.TestTLSSkipVerify(), |
| 49 | base.UnitTestUrl(), |
| 50 | base.TestClusterUsername(), |
| 51 | base.TestClusterPassword(), |
| 52 | tb.GetName(), |
| 53 | ) |
| 54 | |
| 55 | tmpDir := t.TempDir() |
| 56 | |
| 57 | configPath := filepath.Join(tmpDir, "config.json") |
| 58 | err := os.WriteFile(configPath, []byte(config), os.FileMode(0644)) |
| 59 | require.NoError(t, err) |
| 60 | |
| 61 | startupConfig, _, _, _, err := automaticConfigUpgrade(ctx, configPath) |
| 62 | require.NoError(t, err) |
| 63 | |
| 64 | assert.Equal(t, "", startupConfig.Bootstrap.ConfigGroupID) |
| 65 | assert.Equal(t, base.UnitTestUrl(), startupConfig.Bootstrap.Server) |
| 66 | assert.Equal(t, base.TestClusterUsername(), startupConfig.Bootstrap.Username) |
| 67 | assert.Equal(t, base.TestClusterPassword(), startupConfig.Bootstrap.Password) |
| 68 | assert.Equal(t, ":4444", startupConfig.API.PublicInterface) |
| 69 | assert.Equal(t, ":4445", startupConfig.API.AdminInterface) |
| 70 | |
| 71 | writtenNewFile, err := os.ReadFile(configPath) |
| 72 | require.NoError(t, err) |
| 73 | |
| 74 | var writtenFileStartupConfig StartupConfig |
| 75 | err = json.Unmarshal(writtenNewFile, &writtenFileStartupConfig) |
| 76 | require.NoError(t, err) |
| 77 | |
| 78 | assert.Equal(t, "", startupConfig.Bootstrap.ConfigGroupID) |
| 79 | assert.Equal(t, base.UnitTestUrl(), writtenFileStartupConfig.Bootstrap.Server) |
| 80 | assert.Equal(t, base.TestClusterUsername(), writtenFileStartupConfig.Bootstrap.Username) |
| 81 | assert.Equal(t, base.TestClusterPassword(), writtenFileStartupConfig.Bootstrap.Password) |
| 82 | assert.Equal(t, ":4444", writtenFileStartupConfig.API.PublicInterface) |
| 83 | assert.Equal(t, ":4445", writtenFileStartupConfig.API.AdminInterface) |
nothing calls this directly
no test coverage detected