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.Assert(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.Assert(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.Assert(err, check.IsNil)
197 c.Assert(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(err, check.IsNil)
209 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
211 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
212 _, err = testLoadLegacyConfig(content, f, c)
213 c.Check(err, check.NotNil)
215 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
216 _, err = testLoadLegacyConfig(content, f, c)
217 c.Check(err, check.NotNil)
219 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
220 _, err = testLoadLegacyConfig(content, f, c)
221 c.Check(err, check.NotNil)
223 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
224 _, err = testLoadLegacyConfig(content, f, c)
225 c.Check(err, check.IsNil)
228 func fmtKeepproxyConfig(param string, debugLog bool) string {
233 "APIHost": "example.com",
234 "AuthToken": "abcdefg",
238 "DefaultReplicas": 0,
242 "ManagementToken": "xyzzy"
247 func (s *LoadSuite) TestLegacyArvGitHttpdConfig(c *check.C) {
252 "APIHost": "example.com",
253 "AuthToken": "abcdefg",
256 "GitCommand": "/test/git",
257 "GitoliteHome": "/test/gitolite",
258 "RepoRoot": "/test/reporoot",
259 "ManagementToken": "xyzzy"
262 f := "-legacy-git-httpd-config"
263 cluster, err := testLoadLegacyConfig(content, f, c)
265 c.Assert(err, check.IsNil)
266 c.Assert(cluster, check.NotNil)
267 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com", Path: "/"})
268 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
269 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
270 c.Check(cluster.Git.GitCommand, check.Equals, "/test/git")
271 c.Check(cluster.Git.GitoliteHome, check.Equals, "/test/gitolite")
272 c.Check(cluster.Git.Repositories, check.Equals, "/test/reporoot")
273 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":9000"}], check.Equals, arvados.ServiceInstance{})
276 // Tests fix for https://dev.arvados.org/issues/15642
277 func (s *LoadSuite) TestLegacyArvGitHttpdConfigDoesntDisableMissingItems(c *check.C) {
282 "APIHost": "example.com",
283 "AuthToken": "abcdefg",
287 cluster, err := testLoadLegacyConfig(content, "-legacy-git-httpd-config", c)
288 c.Assert(err, check.IsNil)
289 // The resulting ManagementToken should be the one set up on the test server.
290 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
293 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
294 f := "-legacy-keepbalance-config"
295 content := []byte(fmtKeepBalanceConfig(""))
296 cluster, err := testLoadLegacyConfig(content, f, c)
298 c.Assert(err, check.IsNil)
299 c.Assert(cluster, check.NotNil)
300 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
301 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
302 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
303 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
304 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
305 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
306 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
308 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
309 _, err = testLoadLegacyConfig(content, f, c)
310 c.Check(err, check.IsNil)
312 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
313 _, err = testLoadLegacyConfig(content, f, c)
314 c.Check(err, check.IsNil)
316 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
317 _, err = testLoadLegacyConfig(content, f, c)
318 c.Check(err, check.NotNil)
320 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
321 _, err = testLoadLegacyConfig(content, f, c)
322 c.Check(err, check.NotNil)
324 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
325 _, err = testLoadLegacyConfig(content, f, c)
326 c.Check(err, check.NotNil)
329 func fmtKeepBalanceConfig(param string) string {
334 "APIHost": "example.com",
335 "AuthToken": "abcdefg",
341 "CollectionBatchSize": 100000,
342 "CollectionBuffers": 1000,
343 "RequestTimeout": "30m",
344 "ManagementToken": "xyzzy",
345 "LostBlocksFile": "testfile"