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) TestDeprecatedNodeProfilesToServices(c *check.C) {
51 hostname, err := os.Hostname()
52 c.Assert(err, check.IsNil)
64 arvados-dispatch-cloud:
72 "http://localhost:8000": {}
75 "http://localhost:9004": {}
78 "http://dispatch-host:9006": {}
87 arvados-dispatch-cloud:
92 func (s *LoadSuite) TestDeprecatedLoginBackend(c *check.C) {
98 GoogleClientSecret: bbbb
99 GoogleAlternateEmailAddresses: true
108 AlternateEmailAddresses: true
115 ProviderAppSecret: bbbb
123 ProviderAppSecret: bbbb
127 func (s *LoadSuite) TestLegacyKeepWebConfig(c *check.C) {
132 "APIHost": "example.com",
133 "AuthToken": "abcdefg",
139 "AttachmentOnlyHost": "download.example.com",
140 "TrustAllContent": true,
144 "MaxCollectionEntries": 42,
145 "MaxCollectionBytes": 1234567890,
146 "MaxPermissionEntries": 100,
147 "MaxUUIDEntries": 100
149 "ManagementToken": "xyzzy"
152 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
153 c.Check(err, check.IsNil)
155 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
156 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
158 c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second))
159 c.Check(cluster.Collections.WebDAVCache.UUIDTTL, check.Equals, arvados.Duration(time.Second))
160 c.Check(cluster.Collections.WebDAVCache.MaxCollectionEntries, check.Equals, 42)
161 c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, int64(1234567890))
162 c.Check(cluster.Collections.WebDAVCache.MaxPermissionEntries, check.Equals, 100)
163 c.Check(cluster.Collections.WebDAVCache.MaxUUIDEntries, check.Equals, 100)
165 c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com", Path: "/"})
166 c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
167 c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
169 c.Check(cluster.Collections.TrustAllContent, check.Equals, true)
170 c.Check(cluster.Users.AnonymousUserToken, check.Equals, "anonusertoken")
171 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
174 // Tests fix for https://dev.arvados.org/issues/15642
175 func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) {
180 "APIHost": "example.com",
181 "AuthToken": "abcdefg",
185 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
186 c.Check(err, check.IsNil)
187 // The resulting ManagementToken should be the one set up on the test server.
188 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
191 func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) {
192 f := "-legacy-keepproxy-config"
193 content := []byte(fmtKeepproxyConfig("", true))
194 cluster, err := testLoadLegacyConfig(content, f, c)
196 c.Check(err, check.IsNil)
197 c.Check(cluster, check.NotNil)
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")
200 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
201 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
202 c.Check(cluster.Collections.DefaultReplication, check.Equals, 0)
203 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "15s")
204 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "debug")
206 content = []byte(fmtKeepproxyConfig("", false))
207 cluster, err = testLoadLegacyConfig(content, f, c)
208 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
210 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
211 _, err = testLoadLegacyConfig(content, f, c)
212 c.Check(err, check.NotNil)
214 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
215 _, err = testLoadLegacyConfig(content, f, c)
216 c.Check(err, check.NotNil)
218 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
219 _, err = testLoadLegacyConfig(content, f, c)
220 c.Check(err, check.NotNil)
222 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
223 _, err = testLoadLegacyConfig(content, f, c)
224 c.Check(err, check.IsNil)
227 func fmtKeepproxyConfig(param string, debugLog bool) string {
232 "APIHost": "example.com",
233 "AuthToken": "abcdefg",
237 "DefaultReplicas": 0,
241 "ManagementToken": "xyzzy"
246 func (s *LoadSuite) TestLegacyArvGitHttpdConfig(c *check.C) {
251 "APIHost": "example.com",
252 "AuthToken": "abcdefg",
255 "GitCommand": "/test/git",
256 "GitoliteHome": "/test/gitolite",
257 "RepoRoot": "/test/reporoot",
258 "ManagementToken": "xyzzy"
261 f := "-legacy-git-httpd-config"
262 cluster, err := testLoadLegacyConfig(content, f, c)
264 c.Check(err, check.IsNil)
265 c.Check(cluster, check.NotNil)
266 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
267 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
268 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
269 c.Check(cluster.Git.GitCommand, check.Equals, "/test/git")
270 c.Check(cluster.Git.GitoliteHome, check.Equals, "/test/gitolite")
271 c.Check(cluster.Git.Repositories, check.Equals, "/test/reporoot")
272 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":9000"}], check.Equals, arvados.ServiceInstance{})
275 // Tests fix for https://dev.arvados.org/issues/15642
276 func (s *LoadSuite) TestLegacyArvGitHttpdConfigDoesntDisableMissingItems(c *check.C) {
281 "APIHost": "example.com",
282 "AuthToken": "abcdefg",
286 cluster, err := testLoadLegacyConfig(content, "-legacy-git-httpd-config", c)
287 c.Check(err, check.IsNil)
288 // The resulting ManagementToken should be the one set up on the test server.
289 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
292 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
293 f := "-legacy-keepbalance-config"
294 content := []byte(fmtKeepBalanceConfig(""))
295 cluster, err := testLoadLegacyConfig(content, f, c)
297 c.Check(err, check.IsNil)
298 c.Check(cluster, check.NotNil)
299 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
300 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
301 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
302 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
303 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
304 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
305 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
307 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
308 _, err = testLoadLegacyConfig(content, f, c)
309 c.Check(err, check.IsNil)
311 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
312 _, err = testLoadLegacyConfig(content, f, c)
313 c.Check(err, check.IsNil)
315 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
316 _, err = testLoadLegacyConfig(content, f, c)
317 c.Check(err, check.NotNil)
319 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
320 _, err = testLoadLegacyConfig(content, f, c)
321 c.Check(err, check.NotNil)
323 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
324 _, err = testLoadLegacyConfig(content, f, c)
325 c.Check(err, check.NotNil)
328 func fmtKeepBalanceConfig(param string) string {
333 "APIHost": "example.com",
334 "AuthToken": "abcdefg",
340 "CollectionBatchSize": 100000,
341 "CollectionBuffers": 1000,
342 "RequestTimeout": "30m",
343 "ManagementToken": "xyzzy",
344 "LostBlocksFile": "testfile"