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)
39 cfg, err := ldr.Load()
43 cluster, err := cfg.GetCluster("")
50 func (s *LoadSuite) TestLegacyVolumeDriverParameters(c *check.C) {
51 logs := checkEquivalent(c, `
55 z1111-nyw5e-aaaaaaaaaaaaaaa:
58 AccessKey: exampleaccesskey
59 SecretKey: examplesecretkey
66 z1111-nyw5e-aaaaaaaaaaaaaaa:
69 AccessKeyID: exampleaccesskey
70 SecretAccessKey: examplesecretkey
74 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*AccessKey.*`)
75 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*SecretKey.*`)
76 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.*`)
78 _, err := testLoader(c, `
82 z1111-nyw5e-aaaaaaaaaaaaaaa:
85 AccessKey: exampleaccesskey
86 SecretKey: examplesecretkey
87 AccessKeyID: exampleaccesskey
89 c.Check(err, check.ErrorMatches, `(?ms).*cannot use .*SecretKey.*and.*SecretAccessKey.*in z1111.Volumes.z1111-nyw5e-aaaaaaaaaaaaaaa.DriverParameters.*`)
92 func (s *LoadSuite) TestDeprecatedNodeProfilesToServices(c *check.C) {
93 hostname, err := os.Hostname()
94 c.Assert(err, check.IsNil)
106 arvados-dispatch-cloud:
114 "http://localhost:8000": {}
117 "http://localhost:9004": {}
120 "http://dispatch-host:9006": {}
129 arvados-dispatch-cloud:
134 func (s *LoadSuite) TestDeprecatedLoginBackend(c *check.C) {
140 GoogleClientSecret: bbbb
141 GoogleAlternateEmailAddresses: true
150 AlternateEmailAddresses: true
157 ProviderAppSecret: bbbb
165 ProviderAppSecret: bbbb
169 func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) {
174 "APIHost": "example.com",
175 "AuthToken": "abcdefg",
181 "AttachmentOnlyHost": "download.example.com",
182 "TrustAllContent": true,
186 "MaxCollectionEntries": 42,
187 "MaxCollectionBytes": 1234567890,
188 "MaxPermissionEntries": 100,
189 "MaxUUIDEntries": 100
191 "ManagementToken": "xyzzy"
194 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
195 c.Assert(err, check.IsNil)
197 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
198 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
200 c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second))
201 c.Check(cluster.Collections.WebDAVCache.UUIDTTL, check.Equals, arvados.Duration(time.Second))
202 c.Check(cluster.Collections.WebDAVCache.MaxCollectionEntries, check.Equals, 42)
203 c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, int64(1234567890))
204 c.Check(cluster.Collections.WebDAVCache.MaxPermissionEntries, check.Equals, 100)
205 c.Check(cluster.Collections.WebDAVCache.MaxUUIDEntries, check.Equals, 100)
207 c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com", Path: "/"})
208 c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
209 c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
211 c.Check(cluster.Collections.TrustAllContent, check.Equals, true)
212 c.Check(cluster.Users.AnonymousUserToken, check.Equals, "anonusertoken")
213 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
216 // Tests fix for https://dev.arvados.org/issues/15642
217 func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) {
222 "APIHost": "example.com",
223 "AuthToken": "abcdefg",
227 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
228 c.Assert(err, check.IsNil)
229 // The resulting ManagementToken should be the one set up on the test server.
230 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
233 func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) {
234 f := "-legacy-keepproxy-config"
235 content := []byte(fmtKeepproxyConfig("", true))
236 cluster, err := testLoadLegacyConfig(content, f, c)
238 c.Assert(err, check.IsNil)
239 c.Assert(cluster, check.NotNil)
240 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
241 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
242 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
243 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
244 c.Check(cluster.Collections.DefaultReplication, check.Equals, 0)
245 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "15s")
246 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "debug")
248 content = []byte(fmtKeepproxyConfig("", false))
249 cluster, err = testLoadLegacyConfig(content, f, c)
250 c.Check(err, check.IsNil)
251 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
253 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
254 _, err = testLoadLegacyConfig(content, f, c)
255 c.Check(err, check.NotNil)
257 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
258 _, err = testLoadLegacyConfig(content, f, c)
259 c.Check(err, check.NotNil)
261 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
262 _, err = testLoadLegacyConfig(content, f, c)
263 c.Check(err, check.NotNil)
265 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
266 _, err = testLoadLegacyConfig(content, f, c)
267 c.Check(err, check.IsNil)
270 func fmtKeepproxyConfig(param string, debugLog bool) string {
275 "APIHost": "example.com",
276 "AuthToken": "abcdefg",
280 "DefaultReplicas": 0,
284 "ManagementToken": "xyzzy"
289 func (s *LoadSuite) TestLegacyArvGitHttpdConfig(c *check.C) {
294 "APIHost": "example.com",
295 "AuthToken": "abcdefg",
298 "GitCommand": "/test/git",
299 "GitoliteHome": "/test/gitolite",
300 "RepoRoot": "/test/reporoot",
301 "ManagementToken": "xyzzy"
304 f := "-legacy-git-httpd-config"
305 cluster, err := testLoadLegacyConfig(content, f, c)
307 c.Assert(err, check.IsNil)
308 c.Assert(cluster, check.NotNil)
309 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
310 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
311 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
312 c.Check(cluster.Git.GitCommand, check.Equals, "/test/git")
313 c.Check(cluster.Git.GitoliteHome, check.Equals, "/test/gitolite")
314 c.Check(cluster.Git.Repositories, check.Equals, "/test/reporoot")
315 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":9000"}], check.Equals, arvados.ServiceInstance{})
318 // Tests fix for https://dev.arvados.org/issues/15642
319 func (s *LoadSuite) TestLegacyArvGitHttpdConfigDoesntDisableMissingItems(c *check.C) {
324 "APIHost": "example.com",
325 "AuthToken": "abcdefg",
329 cluster, err := testLoadLegacyConfig(content, "-legacy-git-httpd-config", c)
330 c.Assert(err, check.IsNil)
331 // The resulting ManagementToken should be the one set up on the test server.
332 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
335 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
336 f := "-legacy-keepbalance-config"
337 content := []byte(fmtKeepBalanceConfig(""))
338 cluster, err := testLoadLegacyConfig(content, f, c)
340 c.Assert(err, check.IsNil)
341 c.Assert(cluster, check.NotNil)
342 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
343 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
344 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
345 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
346 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
347 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
348 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
350 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
351 _, err = testLoadLegacyConfig(content, f, c)
352 c.Check(err, check.IsNil)
354 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
355 _, err = testLoadLegacyConfig(content, f, c)
356 c.Check(err, check.IsNil)
358 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
359 _, err = testLoadLegacyConfig(content, f, c)
360 c.Check(err, check.NotNil)
362 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
363 _, err = testLoadLegacyConfig(content, f, c)
364 c.Check(err, check.NotNil)
366 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
367 _, err = testLoadLegacyConfig(content, f, c)
368 c.Check(err, check.NotNil)
371 func fmtKeepBalanceConfig(param string) string {
376 "APIHost": "example.com",
377 "AuthToken": "abcdefg",
383 "CollectionBatchSize": 100000,
384 "CollectionBuffers": 1000,
385 "RequestTimeout": "30m",
386 "ManagementToken": "xyzzy",
387 "LostBlocksFile": "testfile"