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.*`)
78 func (s *LoadSuite) TestDeprecatedNodeProfilesToServices(c *check.C) {
79 hostname, err := os.Hostname()
80 c.Assert(err, check.IsNil)
92 arvados-dispatch-cloud:
100 "http://localhost:8000": {}
103 "http://localhost:9004": {}
106 "http://dispatch-host:9006": {}
115 arvados-dispatch-cloud:
120 func (s *LoadSuite) TestDeprecatedLoginBackend(c *check.C) {
126 GoogleClientSecret: bbbb
127 GoogleAlternateEmailAddresses: true
136 AlternateEmailAddresses: true
143 ProviderAppSecret: bbbb
151 ProviderAppSecret: bbbb
155 func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) {
160 "APIHost": "example.com",
161 "AuthToken": "abcdefg",
167 "AttachmentOnlyHost": "download.example.com",
168 "TrustAllContent": true,
172 "MaxCollectionEntries": 42,
173 "MaxCollectionBytes": 1234567890,
174 "MaxPermissionEntries": 100,
175 "MaxUUIDEntries": 100
177 "ManagementToken": "xyzzy"
180 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
181 c.Assert(err, check.IsNil)
183 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
184 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
186 c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second))
187 c.Check(cluster.Collections.WebDAVCache.UUIDTTL, check.Equals, arvados.Duration(time.Second))
188 c.Check(cluster.Collections.WebDAVCache.MaxCollectionEntries, check.Equals, 42)
189 c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, int64(1234567890))
190 c.Check(cluster.Collections.WebDAVCache.MaxPermissionEntries, check.Equals, 100)
191 c.Check(cluster.Collections.WebDAVCache.MaxUUIDEntries, check.Equals, 100)
193 c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com", Path: "/"})
194 c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
195 c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
197 c.Check(cluster.Collections.TrustAllContent, check.Equals, true)
198 c.Check(cluster.Users.AnonymousUserToken, check.Equals, "anonusertoken")
199 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
202 // Tests fix for https://dev.arvados.org/issues/15642
203 func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) {
208 "APIHost": "example.com",
209 "AuthToken": "abcdefg",
213 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
214 c.Assert(err, check.IsNil)
215 // The resulting ManagementToken should be the one set up on the test server.
216 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
219 func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) {
220 f := "-legacy-keepproxy-config"
221 content := []byte(fmtKeepproxyConfig("", true))
222 cluster, err := testLoadLegacyConfig(content, f, c)
224 c.Assert(err, check.IsNil)
225 c.Assert(cluster, check.NotNil)
226 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
227 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
228 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
229 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
230 c.Check(cluster.Collections.DefaultReplication, check.Equals, 0)
231 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "15s")
232 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "debug")
234 content = []byte(fmtKeepproxyConfig("", false))
235 cluster, err = testLoadLegacyConfig(content, f, c)
236 c.Check(err, check.IsNil)
237 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
239 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
240 _, err = testLoadLegacyConfig(content, f, c)
241 c.Check(err, check.NotNil)
243 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
244 _, err = testLoadLegacyConfig(content, f, c)
245 c.Check(err, check.NotNil)
247 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
248 _, err = testLoadLegacyConfig(content, f, c)
249 c.Check(err, check.NotNil)
251 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
252 _, err = testLoadLegacyConfig(content, f, c)
253 c.Check(err, check.IsNil)
256 func fmtKeepproxyConfig(param string, debugLog bool) string {
261 "APIHost": "example.com",
262 "AuthToken": "abcdefg",
266 "DefaultReplicas": 0,
270 "ManagementToken": "xyzzy"
275 func (s *LoadSuite) TestLegacyArvGitHttpdConfig(c *check.C) {
280 "APIHost": "example.com",
281 "AuthToken": "abcdefg",
284 "GitCommand": "/test/git",
285 "GitoliteHome": "/test/gitolite",
286 "RepoRoot": "/test/reporoot",
287 "ManagementToken": "xyzzy"
290 f := "-legacy-git-httpd-config"
291 cluster, err := testLoadLegacyConfig(content, f, c)
293 c.Assert(err, check.IsNil)
294 c.Assert(cluster, check.NotNil)
295 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
296 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
297 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
298 c.Check(cluster.Git.GitCommand, check.Equals, "/test/git")
299 c.Check(cluster.Git.GitoliteHome, check.Equals, "/test/gitolite")
300 c.Check(cluster.Git.Repositories, check.Equals, "/test/reporoot")
301 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":9000"}], check.Equals, arvados.ServiceInstance{})
304 // Tests fix for https://dev.arvados.org/issues/15642
305 func (s *LoadSuite) TestLegacyArvGitHttpdConfigDoesntDisableMissingItems(c *check.C) {
310 "APIHost": "example.com",
311 "AuthToken": "abcdefg",
315 cluster, err := testLoadLegacyConfig(content, "-legacy-git-httpd-config", c)
316 c.Assert(err, check.IsNil)
317 // The resulting ManagementToken should be the one set up on the test server.
318 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
321 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
322 f := "-legacy-keepbalance-config"
323 content := []byte(fmtKeepBalanceConfig(""))
324 cluster, err := testLoadLegacyConfig(content, f, c)
326 c.Assert(err, check.IsNil)
327 c.Assert(cluster, check.NotNil)
328 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
329 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
330 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
331 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
332 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
333 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
334 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
336 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
337 _, err = testLoadLegacyConfig(content, f, c)
338 c.Check(err, check.IsNil)
340 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
341 _, err = testLoadLegacyConfig(content, f, c)
342 c.Check(err, check.IsNil)
344 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
345 _, err = testLoadLegacyConfig(content, f, c)
346 c.Check(err, check.NotNil)
348 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
349 _, err = testLoadLegacyConfig(content, f, c)
350 c.Check(err, check.NotNil)
352 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
353 _, err = testLoadLegacyConfig(content, f, c)
354 c.Check(err, check.NotNil)
357 func fmtKeepBalanceConfig(param string) string {
362 "APIHost": "example.com",
363 "AuthToken": "abcdefg",
369 "CollectionBatchSize": 100000,
370 "CollectionBuffers": 1000,
371 "RequestTimeout": "30m",
372 "ManagementToken": "xyzzy",
373 "LostBlocksFile": "testfile"