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.*`)
79 func (s *LoadSuite) TestDeprecatedNodeProfilesToServices(c *check.C) {
80 hostname, err := os.Hostname()
81 c.Assert(err, check.IsNil)
93 arvados-dispatch-cloud:
101 "http://localhost:8000": {}
104 "http://localhost:9004": {}
107 "http://dispatch-host:9006": {}
116 arvados-dispatch-cloud:
121 func (s *LoadSuite) TestDeprecatedLoginBackend(c *check.C) {
127 GoogleClientSecret: bbbb
128 GoogleAlternateEmailAddresses: true
137 AlternateEmailAddresses: true
144 ProviderAppSecret: bbbb
152 ProviderAppSecret: bbbb
156 func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) {
161 "APIHost": "example.com",
162 "AuthToken": "abcdefg",
168 "AttachmentOnlyHost": "download.example.com",
169 "TrustAllContent": true,
173 "MaxCollectionEntries": 42,
174 "MaxCollectionBytes": 1234567890,
175 "MaxPermissionEntries": 100,
176 "MaxUUIDEntries": 100
178 "ManagementToken": "xyzzy"
181 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
182 c.Assert(err, check.IsNil)
184 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
185 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
187 c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second))
188 c.Check(cluster.Collections.WebDAVCache.UUIDTTL, check.Equals, arvados.Duration(time.Second))
189 c.Check(cluster.Collections.WebDAVCache.MaxCollectionEntries, check.Equals, 42)
190 c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, int64(1234567890))
191 c.Check(cluster.Collections.WebDAVCache.MaxPermissionEntries, check.Equals, 100)
192 c.Check(cluster.Collections.WebDAVCache.MaxUUIDEntries, check.Equals, 100)
194 c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com", Path: "/"})
195 c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
196 c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
198 c.Check(cluster.Collections.TrustAllContent, check.Equals, true)
199 c.Check(cluster.Users.AnonymousUserToken, check.Equals, "anonusertoken")
200 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
203 // Tests fix for https://dev.arvados.org/issues/15642
204 func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) {
209 "APIHost": "example.com",
210 "AuthToken": "abcdefg",
214 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
215 c.Assert(err, check.IsNil)
216 // The resulting ManagementToken should be the one set up on the test server.
217 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
220 func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) {
221 f := "-legacy-keepproxy-config"
222 content := []byte(fmtKeepproxyConfig("", true))
223 cluster, err := testLoadLegacyConfig(content, f, c)
225 c.Assert(err, check.IsNil)
226 c.Assert(cluster, check.NotNil)
227 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
228 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
229 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
230 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
231 c.Check(cluster.Collections.DefaultReplication, check.Equals, 0)
232 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "15s")
233 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "debug")
235 content = []byte(fmtKeepproxyConfig("", false))
236 cluster, err = testLoadLegacyConfig(content, f, c)
237 c.Check(err, check.IsNil)
238 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
240 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
241 _, err = testLoadLegacyConfig(content, f, c)
242 c.Check(err, check.NotNil)
244 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
245 _, err = testLoadLegacyConfig(content, f, c)
246 c.Check(err, check.NotNil)
248 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
249 _, err = testLoadLegacyConfig(content, f, c)
250 c.Check(err, check.NotNil)
252 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
253 _, err = testLoadLegacyConfig(content, f, c)
254 c.Check(err, check.IsNil)
257 func fmtKeepproxyConfig(param string, debugLog bool) string {
262 "APIHost": "example.com",
263 "AuthToken": "abcdefg",
267 "DefaultReplicas": 0,
271 "ManagementToken": "xyzzy"
276 func (s *LoadSuite) TestLegacyArvGitHttpdConfig(c *check.C) {
281 "APIHost": "example.com",
282 "AuthToken": "abcdefg",
285 "GitCommand": "/test/git",
286 "GitoliteHome": "/test/gitolite",
287 "RepoRoot": "/test/reporoot",
288 "ManagementToken": "xyzzy"
291 f := "-legacy-git-httpd-config"
292 cluster, err := testLoadLegacyConfig(content, f, c)
294 c.Assert(err, check.IsNil)
295 c.Assert(cluster, check.NotNil)
296 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
297 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
298 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
299 c.Check(cluster.Git.GitCommand, check.Equals, "/test/git")
300 c.Check(cluster.Git.GitoliteHome, check.Equals, "/test/gitolite")
301 c.Check(cluster.Git.Repositories, check.Equals, "/test/reporoot")
302 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":9000"}], check.Equals, arvados.ServiceInstance{})
305 // Tests fix for https://dev.arvados.org/issues/15642
306 func (s *LoadSuite) TestLegacyArvGitHttpdConfigDoesntDisableMissingItems(c *check.C) {
311 "APIHost": "example.com",
312 "AuthToken": "abcdefg",
316 cluster, err := testLoadLegacyConfig(content, "-legacy-git-httpd-config", c)
317 c.Assert(err, check.IsNil)
318 // The resulting ManagementToken should be the one set up on the test server.
319 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
322 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
323 f := "-legacy-keepbalance-config"
324 content := []byte(fmtKeepBalanceConfig(""))
325 cluster, err := testLoadLegacyConfig(content, f, c)
327 c.Assert(err, check.IsNil)
328 c.Assert(cluster, check.NotNil)
329 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
330 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
331 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
332 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
333 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
334 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
335 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
337 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
338 _, err = testLoadLegacyConfig(content, f, c)
339 c.Check(err, check.IsNil)
341 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
342 _, err = testLoadLegacyConfig(content, f, c)
343 c.Check(err, check.IsNil)
345 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
346 _, err = testLoadLegacyConfig(content, f, c)
347 c.Check(err, check.NotNil)
349 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
350 _, err = testLoadLegacyConfig(content, f, c)
351 c.Check(err, check.NotNil)
353 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
354 _, err = testLoadLegacyConfig(content, f, c)
355 c.Check(err, check.NotNil)
358 func fmtKeepBalanceConfig(param string) string {
363 "APIHost": "example.com",
364 "AuthToken": "abcdefg",
370 "CollectionBatchSize": 100000,
371 "CollectionBuffers": 1000,
372 "RequestTimeout": "30m",
373 "ManagementToken": "xyzzy",
374 "LostBlocksFile": "testfile"