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) TestLegacyVolumeDriverParameters(c *check.C) {
53 logs := checkEquivalent(c, `
57 z1111-nyw5e-aaaaaaaaaaaaaaa:
60 AccessKey: exampleaccesskey
61 SecretKey: examplesecretkey
68 z1111-nyw5e-aaaaaaaaaaaaaaa:
71 AccessKeyID: exampleaccesskey
72 SecretAccessKey: examplesecretkey
76 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*AccessKey.*`)
77 c.Check(logs, check.Matches, `(?ms).*deprecated or unknown config entry: .*SecretKey.*`)
78 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.*`)
80 _, err := testLoader(c, `
84 z1111-nyw5e-aaaaaaaaaaaaaaa:
87 AccessKey: exampleaccesskey
88 SecretKey: examplesecretkey
89 AccessKeyID: exampleaccesskey
91 c.Check(err, check.ErrorMatches, `(?ms).*cannot use .*SecretKey.*and.*SecretAccessKey.*in z1111.Volumes.z1111-nyw5e-aaaaaaaaaaaaaaa.DriverParameters.*`)
94 func (s *LoadSuite) TestDeprecatedNodeProfilesToServices(c *check.C) {
95 hostname, err := os.Hostname()
96 c.Assert(err, check.IsNil)
108 arvados-dispatch-cloud:
116 "http://localhost:8000": {}
119 "http://localhost:9004": {}
122 "http://dispatch-host:9006": {}
131 arvados-dispatch-cloud:
136 func (s *LoadSuite) TestDeprecatedLoginBackend(c *check.C) {
142 GoogleClientSecret: bbbb
143 GoogleAlternateEmailAddresses: true
152 AlternateEmailAddresses: true
159 ProviderAppSecret: bbbb
167 ProviderAppSecret: bbbb
171 func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) {
176 "APIHost": "example.com",
177 "AuthToken": "abcdefg",
183 "AttachmentOnlyHost": "download.example.com",
184 "TrustAllContent": true,
188 "MaxCollectionEntries": 42,
189 "MaxCollectionBytes": 1234567890,
190 "MaxUUIDEntries": 100
192 "ManagementToken": "xyzzy"
195 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
196 c.Assert(err, check.IsNil)
198 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
199 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
201 c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second))
202 c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, arvados.ByteSize(1234567890))
204 c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com", Path: "/"})
205 c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
206 c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
208 c.Check(cluster.Collections.TrustAllContent, check.Equals, true)
209 c.Check(cluster.Users.AnonymousUserToken, check.Equals, "anonusertoken")
210 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
213 // Tests fix for https://dev.arvados.org/issues/15642
214 func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) {
219 "APIHost": "example.com",
220 "AuthToken": "abcdefg",
224 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
225 c.Assert(err, check.IsNil)
226 // The resulting ManagementToken should be the one set up on the test server.
227 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
230 func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) {
231 f := "-legacy-keepproxy-config"
232 content := []byte(fmtKeepproxyConfig("", true))
233 cluster, err := testLoadLegacyConfig(content, f, c)
235 c.Assert(err, check.IsNil)
236 c.Assert(cluster, check.NotNil)
237 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
238 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
239 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
240 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
241 c.Check(cluster.Collections.DefaultReplication, check.Equals, 0)
242 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "15s")
243 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "debug")
245 content = []byte(fmtKeepproxyConfig("", false))
246 cluster, err = testLoadLegacyConfig(content, f, c)
247 c.Check(err, check.IsNil)
248 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
250 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
251 _, err = testLoadLegacyConfig(content, f, c)
252 c.Check(err, check.NotNil)
254 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
255 _, err = testLoadLegacyConfig(content, f, c)
256 c.Check(err, check.NotNil)
258 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
259 _, err = testLoadLegacyConfig(content, f, c)
260 c.Check(err, check.NotNil)
262 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
263 _, err = testLoadLegacyConfig(content, f, c)
264 c.Check(err, check.IsNil)
267 func fmtKeepproxyConfig(param string, debugLog bool) string {
272 "APIHost": "example.com",
273 "AuthToken": "abcdefg",
277 "DefaultReplicas": 0,
281 "ManagementToken": "xyzzy"
286 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
287 f := "-legacy-keepbalance-config"
288 content := []byte(fmtKeepBalanceConfig(""))
289 cluster, err := testLoadLegacyConfig(content, f, c)
291 c.Assert(err, check.IsNil)
292 c.Assert(cluster, check.NotNil)
293 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
294 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
295 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
296 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
297 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
298 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
299 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
301 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
302 _, err = testLoadLegacyConfig(content, f, c)
303 c.Check(err, check.IsNil)
305 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
306 _, err = testLoadLegacyConfig(content, f, c)
307 c.Check(err, check.IsNil)
309 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
310 _, err = testLoadLegacyConfig(content, f, c)
311 c.Check(err, check.NotNil)
313 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
314 _, err = testLoadLegacyConfig(content, f, c)
315 c.Check(err, check.NotNil)
317 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
318 _, err = testLoadLegacyConfig(content, f, c)
319 c.Check(err, check.NotNil)
322 func fmtKeepBalanceConfig(param string) string {
327 "APIHost": "example.com",
328 "AuthToken": "abcdefg",
334 "CollectionBatchSize": 100000,
335 "CollectionBuffers": 1000,
336 "RequestTimeout": "30m",
337 "ManagementToken": "xyzzy",
338 "LostBlocksFile": "testfile"