1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
14 "git.arvados.org/arvados.git/sdk/go/arvados"
15 check "gopkg.in/check.v1"
18 // Configured at: sdk/python/tests/run_test_server.py
19 const TestServerManagementToken = "e687950a23c3a9bceec28c6223a06c79"
21 func testLoadLegacyConfig(content []byte, mungeFlag string, c *check.C) (*arvados.Cluster, error) {
22 tmpfile, err := ioutil.TempFile("", "example")
26 defer os.Remove(tmpfile.Name())
28 if _, err := tmpfile.Write(content); err != nil {
31 if err := tmpfile.Close(); err != nil {
34 flags := flag.NewFlagSet("test", flag.ExitOnError)
35 ldr := testLoader(c, "Clusters: {zzzzz: {}}", nil)
37 args := ldr.MungeLegacyConfigArgs(ldr.Logger, []string{"-config", tmpfile.Name()}, mungeFlag)
38 err = flags.Parse(args)
39 c.Assert(err, check.IsNil)
40 c.Assert(flags.NArg(), check.Equals, 0)
41 cfg, err := ldr.Load()
45 cluster, err := cfg.GetCluster("")
52 func (s *LoadSuite) TestOldEmailConfiguration(c *check.C) {
53 logs := checkEquivalent(c, `
57 SendUserSetupNotificationEmail: false
58 SupportEmailAddress: "support@example.invalid"
63 SendUserSetupNotificationEmail: false
64 SupportEmailAddress: "support@example.invalid"
66 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*Mail\.SendUserSetupNotificationEmail.*`)
67 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*Mail\.SupportEmailAddress.*`)
68 c.Check(logs, check.Matches, `(?ms).*using your old config key Mail\.SendUserSetupNotificationEmail -- but you should rename it to Users\.SendUserSetupNotificationEmail.*`)
69 c.Check(logs, check.Matches, `(?ms).*using your old config key Mail\.SupportEmailAddress -- but you should rename it to Users\.SupportEmailAddress.*`)
72 func (s *LoadSuite) TestLegacyVolumeDriverParameters(c *check.C) {
73 logs := checkEquivalent(c, `
77 z1111-nyw5e-aaaaaaaaaaaaaaa:
80 AccessKey: exampleaccesskey
81 SecretKey: examplesecretkey
88 z1111-nyw5e-aaaaaaaaaaaaaaa:
91 AccessKeyID: exampleaccesskey
92 SecretAccessKey: examplesecretkey
96 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*AccessKey.*`)
97 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*SecretKey.*`)
98 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.*`)
100 _, err := testLoader(c, `
104 z1111-nyw5e-aaaaaaaaaaaaaaa:
107 AccessKey: exampleaccesskey
108 SecretKey: examplesecretkey
109 AccessKeyID: exampleaccesskey
111 c.Check(err, check.ErrorMatches, `(?ms).*cannot use .*SecretKey.*and.*SecretAccessKey.*in z1111.Volumes.z1111-nyw5e-aaaaaaaaaaaaaaa.DriverParameters.*`)
114 func (s *LoadSuite) TestDeprecatedNodeProfilesToServices(c *check.C) {
115 hostname, err := os.Hostname()
116 c.Assert(err, check.IsNil)
128 arvados-dispatch-cloud:
136 "http://localhost:8000": {}
139 "http://localhost:9004": {}
142 "http://dispatch-host:9006": {}
151 arvados-dispatch-cloud:
156 func (s *LoadSuite) TestDeprecatedLoginBackend(c *check.C) {
162 GoogleClientSecret: bbbb
163 GoogleAlternateEmailAddresses: true
172 AlternateEmailAddresses: true
179 ProviderAppSecret: bbbb
187 ProviderAppSecret: bbbb
191 func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) {
196 "APIHost": "example.com",
197 "AuthToken": "abcdefg",
203 "AttachmentOnlyHost": "download.example.com",
204 "TrustAllContent": true,
208 "MaxCollectionEntries": 42,
209 "MaxCollectionBytes": 1234567890,
210 "MaxUUIDEntries": 100
212 "ManagementToken": "xyzzy"
215 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
216 c.Assert(err, check.IsNil)
218 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
219 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
221 c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second))
222 c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, arvados.ByteSize(1234567890))
224 c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com", Path: "/"})
225 c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
226 c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
228 c.Check(cluster.Collections.TrustAllContent, check.Equals, true)
229 c.Check(cluster.Users.AnonymousUserToken, check.Equals, "anonusertoken")
230 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
233 // Tests fix for https://dev.arvados.org/issues/15642
234 func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) {
239 "APIHost": "example.com",
240 "AuthToken": "abcdefg",
244 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
245 c.Assert(err, check.IsNil)
246 // The resulting ManagementToken should be the one set up on the test server.
247 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
250 func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) {
251 f := "-legacy-keepproxy-config"
252 content := []byte(fmtKeepproxyConfig("", true))
253 cluster, err := testLoadLegacyConfig(content, f, c)
255 c.Assert(err, check.IsNil)
256 c.Assert(cluster, check.NotNil)
257 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
258 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
259 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
260 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
261 c.Check(cluster.Collections.DefaultReplication, check.Equals, 0)
262 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "15s")
263 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "debug")
265 content = []byte(fmtKeepproxyConfig("", false))
266 cluster, err = testLoadLegacyConfig(content, f, c)
267 c.Check(err, check.IsNil)
268 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
270 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
271 _, err = testLoadLegacyConfig(content, f, c)
272 c.Check(err, check.NotNil)
274 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
275 _, err = testLoadLegacyConfig(content, f, c)
276 c.Check(err, check.NotNil)
278 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
279 _, err = testLoadLegacyConfig(content, f, c)
280 c.Check(err, check.NotNil)
282 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
283 _, err = testLoadLegacyConfig(content, f, c)
284 c.Check(err, check.IsNil)
287 func fmtKeepproxyConfig(param string, debugLog bool) string {
292 "APIHost": "example.com",
293 "AuthToken": "abcdefg",
297 "DefaultReplicas": 0,
301 "ManagementToken": "xyzzy"
306 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
307 f := "-legacy-keepbalance-config"
308 content := []byte(fmtKeepBalanceConfig(""))
309 cluster, err := testLoadLegacyConfig(content, f, c)
311 c.Assert(err, check.IsNil)
312 c.Assert(cluster, check.NotNil)
313 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
314 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
315 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
316 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
317 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
318 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
319 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
321 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
322 _, err = testLoadLegacyConfig(content, f, c)
323 c.Check(err, check.IsNil)
325 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
326 _, err = testLoadLegacyConfig(content, f, c)
327 c.Check(err, check.IsNil)
329 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
330 _, err = testLoadLegacyConfig(content, f, c)
331 c.Check(err, check.NotNil)
333 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
334 _, err = testLoadLegacyConfig(content, f, c)
335 c.Check(err, check.NotNil)
337 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
338 _, err = testLoadLegacyConfig(content, f, c)
339 c.Check(err, check.NotNil)
342 func fmtKeepBalanceConfig(param string) string {
347 "APIHost": "example.com",
348 "AuthToken": "abcdefg",
354 "CollectionBatchSize": 100000,
355 "CollectionBuffers": 1000,
356 "RequestTimeout": "30m",
357 "ManagementToken": "xyzzy",
358 "LostBlocksFile": "testfile"