X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5ae0a422e60788a4039d17d2d8dfb60f250329c7..63b40a5af92aef28d8416c945ffc7c9805ae8d7d:/lib/config/deprecated_test.go diff --git a/lib/config/deprecated_test.go b/lib/config/deprecated_test.go index 76313ebb16..4206ef5771 100644 --- a/lib/config/deprecated_test.go +++ b/lib/config/deprecated_test.go @@ -11,10 +11,13 @@ import ( "os" "time" - "git.curoverse.com/arvados.git/sdk/go/arvados" + "git.arvados.org/arvados.git/sdk/go/arvados" check "gopkg.in/check.v1" ) +// Configured at: sdk/python/tests/run_test_server.py +const TestServerManagementToken = "e687950a23c3a9bceec28c6223a06c79" + func testLoadLegacyConfig(content []byte, mungeFlag string, c *check.C) (*arvados.Cluster, error) { tmpfile, err := ioutil.TempFile("", "example") if err != nil { @@ -32,7 +35,9 @@ func testLoadLegacyConfig(content []byte, mungeFlag string, c *check.C) (*arvado ldr := testLoader(c, "Clusters: {zzzzz: {}}", nil) ldr.SetupFlags(flags) args := ldr.MungeLegacyConfigArgs(ldr.Logger, []string{"-config", tmpfile.Name()}, mungeFlag) - flags.Parse(args) + err = flags.Parse(args) + c.Assert(err, check.IsNil) + c.Assert(flags.NArg(), check.Equals, 0) cfg, err := ldr.Load() if err != nil { return nil, err @@ -44,10 +49,52 @@ func testLoadLegacyConfig(content []byte, mungeFlag string, c *check.C) (*arvado return cluster, nil } +func (s *LoadSuite) TestLegacyVolumeDriverParameters(c *check.C) { + logs := checkEquivalent(c, ` +Clusters: + z1111: + Volumes: + z1111-nyw5e-aaaaaaaaaaaaaaa: + Driver: S3 + DriverParameters: + AccessKey: exampleaccesskey + SecretKey: examplesecretkey + Region: foobar + ReadTimeout: 1200s +`, ` +Clusters: + z1111: + Volumes: + z1111-nyw5e-aaaaaaaaaaaaaaa: + Driver: S3 + DriverParameters: + AccessKeyID: exampleaccesskey + SecretAccessKey: examplesecretkey + Region: foobar + ReadTimeout: 1200s +`) + c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*AccessKey.*`) + c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*SecretKey.*`) + c.Check(logs, check.Matches, `(?ms).*using your old config keys z1111\.Volumes\.z1111-nyw5e-aaaaaaaaaaaaaaa\.DriverParameters\.AccessKey/SecretKey -- but you should rename them to AccessKeyID/SecretAccessKey.*`) + + _, err := testLoader(c, ` +Clusters: + z1111: + Volumes: + z1111-nyw5e-aaaaaaaaaaaaaaa: + Driver: S3 + DriverParameters: + AccessKey: exampleaccesskey + SecretKey: examplesecretkey + AccessKeyID: exampleaccesskey +`, nil).Load() + c.Check(err, check.ErrorMatches, `(?ms).*cannot use .*SecretKey.*and.*SecretAccessKey.*in z1111.Volumes.z1111-nyw5e-aaaaaaaaaaaaaaa.DriverParameters.*`) +} + func (s *LoadSuite) TestDeprecatedNodeProfilesToServices(c *check.C) { hostname, err := os.Hostname() c.Assert(err, check.IsNil) - s.checkEquivalent(c, ` + checkEquivalent(c, ` Clusters: z1111: NodeProfiles: @@ -86,6 +133,41 @@ Clusters: `) } +func (s *LoadSuite) TestDeprecatedLoginBackend(c *check.C) { + checkEquivalent(c, ` +Clusters: + z1111: + Login: + GoogleClientID: aaaa + GoogleClientSecret: bbbb + GoogleAlternateEmailAddresses: true +`, ` +Clusters: + z1111: + Login: + Google: + Enable: true + ClientID: aaaa + ClientSecret: bbbb + AlternateEmailAddresses: true +`) + checkEquivalent(c, ` +Clusters: + z1111: + Login: + ProviderAppID: aaaa + ProviderAppSecret: bbbb +`, ` +Clusters: + z1111: + Login: + SSO: + Enable: true + ProviderAppID: aaaa + ProviderAppSecret: bbbb +`) +} + func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) { content := []byte(` { @@ -105,26 +187,24 @@ func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) { "UUIDTTL": "1s", "MaxCollectionEntries": 42, "MaxCollectionBytes": 1234567890, - "MaxPermissionEntries": 100, "MaxUUIDEntries": 100 }, "ManagementToken": "xyzzy" } `) cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c) - c.Check(err, check.IsNil) + c.Assert(err, check.IsNil) - c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com"}) + c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"}) c.Check(cluster.SystemRootToken, check.Equals, "abcdefg") c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second)) c.Check(cluster.Collections.WebDAVCache.UUIDTTL, check.Equals, arvados.Duration(time.Second)) c.Check(cluster.Collections.WebDAVCache.MaxCollectionEntries, check.Equals, 42) c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, int64(1234567890)) - c.Check(cluster.Collections.WebDAVCache.MaxPermissionEntries, check.Equals, 100) c.Check(cluster.Collections.WebDAVCache.MaxUUIDEntries, check.Equals, 100) - c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com"}) + c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com", Path: "/"}) c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil) c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil) @@ -133,14 +213,31 @@ func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) { c.Check(cluster.ManagementToken, check.Equals, "xyzzy") } +// Tests fix for https://dev.arvados.org/issues/15642 +func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) { + content := []byte(` +{ + "Client": { + "Scheme": "", + "APIHost": "example.com", + "AuthToken": "abcdefg", + } +} +`) + cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c) + c.Assert(err, check.IsNil) + // The resulting ManagementToken should be the one set up on the test server. + c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken) +} + func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) { f := "-legacy-keepproxy-config" content := []byte(fmtKeepproxyConfig("", true)) cluster, err := testLoadLegacyConfig(content, f, c) - c.Check(err, check.IsNil) - c.Check(cluster, check.NotNil) - c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com"}) + c.Assert(err, check.IsNil) + c.Assert(cluster, check.NotNil) + c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"}) c.Check(cluster.SystemRootToken, check.Equals, "abcdefg") c.Check(cluster.ManagementToken, check.Equals, "xyzzy") c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{}) @@ -150,6 +247,7 @@ func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) { content = []byte(fmtKeepproxyConfig("", false)) cluster, err = testLoadLegacyConfig(content, f, c) + c.Check(err, check.IsNil) c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info") content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true)) @@ -187,3 +285,106 @@ func fmtKeepproxyConfig(param string, debugLog bool) string { } `, debugLog, param) } + +func (s *LoadSuite) TestLegacyArvGitHttpdConfig(c *check.C) { + content := []byte(` +{ + "Client": { + "Scheme": "", + "APIHost": "example.com", + "AuthToken": "abcdefg", + }, + "Listen": ":9000", + "GitCommand": "/test/git", + "GitoliteHome": "/test/gitolite", + "RepoRoot": "/test/reporoot", + "ManagementToken": "xyzzy" +} +`) + f := "-legacy-git-httpd-config" + cluster, err := testLoadLegacyConfig(content, f, c) + + c.Assert(err, check.IsNil) + c.Assert(cluster, check.NotNil) + c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"}) + c.Check(cluster.SystemRootToken, check.Equals, "abcdefg") + c.Check(cluster.ManagementToken, check.Equals, "xyzzy") + c.Check(cluster.Git.GitCommand, check.Equals, "/test/git") + c.Check(cluster.Git.GitoliteHome, check.Equals, "/test/gitolite") + c.Check(cluster.Git.Repositories, check.Equals, "/test/reporoot") + c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":9000"}], check.Equals, arvados.ServiceInstance{}) +} + +// Tests fix for https://dev.arvados.org/issues/15642 +func (s *LoadSuite) TestLegacyArvGitHttpdConfigDoesntDisableMissingItems(c *check.C) { + content := []byte(` +{ + "Client": { + "Scheme": "", + "APIHost": "example.com", + "AuthToken": "abcdefg", + } +} +`) + cluster, err := testLoadLegacyConfig(content, "-legacy-git-httpd-config", c) + c.Assert(err, check.IsNil) + // The resulting ManagementToken should be the one set up on the test server. + c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken) +} + +func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) { + f := "-legacy-keepbalance-config" + content := []byte(fmtKeepBalanceConfig("")) + cluster, err := testLoadLegacyConfig(content, f, c) + + c.Assert(err, check.IsNil) + c.Assert(cluster, check.NotNil) + c.Check(cluster.ManagementToken, check.Equals, "xyzzy") + c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{}) + c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000) + c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000) + c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m") + c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile") + c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m") + + content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`)) + _, err = testLoadLegacyConfig(content, f, c) + c.Check(err, check.IsNil) + + content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`)) + _, err = testLoadLegacyConfig(content, f, c) + c.Check(err, check.IsNil) + + content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`)) + _, err = testLoadLegacyConfig(content, f, c) + c.Check(err, check.NotNil) + + content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`)) + _, err = testLoadLegacyConfig(content, f, c) + c.Check(err, check.NotNil) + + content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`)) + _, err = testLoadLegacyConfig(content, f, c) + c.Check(err, check.NotNil) +} + +func fmtKeepBalanceConfig(param string) string { + return fmt.Sprintf(` +{ + "Client": { + "Scheme": "", + "APIHost": "example.com", + "AuthToken": "abcdefg", + "Insecure": false + }, + "Listen": ":80", + %s + "RunPeriod": "10m", + "CollectionBatchSize": 100000, + "CollectionBuffers": 1000, + "RequestTimeout": "30m", + "ManagementToken": "xyzzy", + "LostBlocksFile": "testfile" +} +`, param) +}