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) TestLegacyKeepWebConfig(c *check.C) {
97 "APIHost": "example.com",
98 "AuthToken": "abcdefg",
104 "AttachmentOnlyHost": "download.example.com",
105 "TrustAllContent": true,
109 "MaxCollectionEntries": 42,
110 "MaxCollectionBytes": 1234567890,
111 "MaxPermissionEntries": 100,
112 "MaxUUIDEntries": 100
114 "ManagementToken": "xyzzy"
117 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
118 c.Check(err, check.IsNil)
120 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com"})
121 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
123 c.Check(cluster.Collections.WebDAVCache.TTL, check.Equals, arvados.Duration(60*time.Second))
124 c.Check(cluster.Collections.WebDAVCache.UUIDTTL, check.Equals, arvados.Duration(time.Second))
125 c.Check(cluster.Collections.WebDAVCache.MaxCollectionEntries, check.Equals, 42)
126 c.Check(cluster.Collections.WebDAVCache.MaxCollectionBytes, check.Equals, int64(1234567890))
127 c.Check(cluster.Collections.WebDAVCache.MaxPermissionEntries, check.Equals, 100)
128 c.Check(cluster.Collections.WebDAVCache.MaxUUIDEntries, check.Equals, 100)
130 c.Check(cluster.Services.WebDAVDownload.ExternalURL, check.Equals, arvados.URL{Host: "download.example.com"})
131 c.Check(cluster.Services.WebDAVDownload.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
132 c.Check(cluster.Services.WebDAV.InternalURLs[arvados.URL{Host: ":80"}], check.NotNil)
134 c.Check(cluster.Collections.TrustAllContent, check.Equals, true)
135 c.Check(cluster.Users.AnonymousUserToken, check.Equals, "anonusertoken")
136 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
139 // Tests fix for https://dev.arvados.org/issues/15642
140 func (s *LoadSuite) TestLegacyKeepWebConfigDoesntDisableMissingItems(c *check.C) {
145 "APIHost": "example.com",
146 "AuthToken": "abcdefg",
150 cluster, err := testLoadLegacyConfig(content, "-legacy-keepweb-config", c)
151 c.Check(err, check.IsNil)
152 // The resulting ManagementToken should be the one set up on the test server.
153 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
156 func (s *LoadSuite) TestLegacyKeepproxyConfig(c *check.C) {
157 f := "-legacy-keepproxy-config"
158 content := []byte(fmtKeepproxyConfig("", true))
159 cluster, err := testLoadLegacyConfig(content, f, c)
161 c.Check(err, check.IsNil)
162 c.Check(cluster, check.NotNil)
163 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com"})
164 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
165 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
166 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
167 c.Check(cluster.Collections.DefaultReplication, check.Equals, 0)
168 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "15s")
169 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "debug")
171 content = []byte(fmtKeepproxyConfig("", false))
172 cluster, err = testLoadLegacyConfig(content, f, c)
173 c.Check(cluster.SystemLogs.LogLevel, check.Equals, "info")
175 content = []byte(fmtKeepproxyConfig(`"DisableGet": true,`, true))
176 _, err = testLoadLegacyConfig(content, f, c)
177 c.Check(err, check.NotNil)
179 content = []byte(fmtKeepproxyConfig(`"DisablePut": true,`, true))
180 _, err = testLoadLegacyConfig(content, f, c)
181 c.Check(err, check.NotNil)
183 content = []byte(fmtKeepproxyConfig(`"PIDFile": "test",`, true))
184 _, err = testLoadLegacyConfig(content, f, c)
185 c.Check(err, check.NotNil)
187 content = []byte(fmtKeepproxyConfig(`"DisableGet": false, "DisablePut": false, "PIDFile": "",`, true))
188 _, err = testLoadLegacyConfig(content, f, c)
189 c.Check(err, check.IsNil)
192 func fmtKeepproxyConfig(param string, debugLog bool) string {
197 "APIHost": "example.com",
198 "AuthToken": "abcdefg",
202 "DefaultReplicas": 0,
206 "ManagementToken": "xyzzy"
211 func (s *LoadSuite) TestLegacyArvGitHttpdConfig(c *check.C) {
216 "APIHost": "example.com",
217 "AuthToken": "abcdefg",
220 "GitCommand": "/test/git",
221 "GitoliteHome": "/test/gitolite",
222 "RepoRoot": "/test/reporoot",
223 "ManagementToken": "xyzzy"
226 f := "-legacy-git-httpd-config"
227 cluster, err := testLoadLegacyConfig(content, f, c)
229 c.Check(err, check.IsNil)
230 c.Check(cluster, check.NotNil)
231 c.Check(cluster.Services.Controller.ExternalURL, check.Equals, arvados.URL{Scheme: "https", Host: "example.com"})
232 c.Check(cluster.SystemRootToken, check.Equals, "abcdefg")
233 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
234 c.Check(cluster.Git.GitCommand, check.Equals, "/test/git")
235 c.Check(cluster.Git.GitoliteHome, check.Equals, "/test/gitolite")
236 c.Check(cluster.Git.Repositories, check.Equals, "/test/reporoot")
237 c.Check(cluster.Services.Keepproxy.InternalURLs[arvados.URL{Host: ":9000"}], check.Equals, arvados.ServiceInstance{})
240 // Tests fix for https://dev.arvados.org/issues/15642
241 func (s *LoadSuite) TestLegacyArvGitHttpdConfigDoesntDisableMissingItems(c *check.C) {
246 "APIHost": "example.com",
247 "AuthToken": "abcdefg",
251 cluster, err := testLoadLegacyConfig(content, "-legacy-git-httpd-config", c)
252 c.Check(err, check.IsNil)
253 // The resulting ManagementToken should be the one set up on the test server.
254 c.Check(cluster.ManagementToken, check.Equals, TestServerManagementToken)
257 func (s *LoadSuite) TestLegacyKeepBalanceConfig(c *check.C) {
258 f := "-legacy-keepbalance-config"
259 content := []byte(fmtKeepBalanceConfig(""))
260 cluster, err := testLoadLegacyConfig(content, f, c)
262 c.Check(err, check.IsNil)
263 c.Check(cluster, check.NotNil)
264 c.Check(cluster.ManagementToken, check.Equals, "xyzzy")
265 c.Check(cluster.Services.Keepbalance.InternalURLs[arvados.URL{Host: ":80"}], check.Equals, arvados.ServiceInstance{})
266 c.Check(cluster.Collections.BalanceCollectionBuffers, check.Equals, 1000)
267 c.Check(cluster.Collections.BalanceCollectionBatch, check.Equals, 100000)
268 c.Check(cluster.Collections.BalancePeriod.String(), check.Equals, "10m")
269 c.Check(cluster.Collections.BlobMissingReport, check.Equals, "testfile")
270 c.Check(cluster.API.KeepServiceRequestTimeout.String(), check.Equals, "30m")
272 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk"],`))
273 _, err = testLoadLegacyConfig(content, f, c)
274 c.Check(err, check.IsNil)
276 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":[],`))
277 _, err = testLoadLegacyConfig(content, f, c)
278 c.Check(err, check.IsNil)
280 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["proxy"],`))
281 _, err = testLoadLegacyConfig(content, f, c)
282 c.Check(err, check.NotNil)
284 content = []byte(fmtKeepBalanceConfig(`"KeepServiceTypes":["disk", "proxy"],`))
285 _, err = testLoadLegacyConfig(content, f, c)
286 c.Check(err, check.NotNil)
288 content = []byte(fmtKeepBalanceConfig(`"KeepServiceList":{},`))
289 _, err = testLoadLegacyConfig(content, f, c)
290 c.Check(err, check.NotNil)
293 func fmtKeepBalanceConfig(param string) string {
298 "APIHost": "example.com",
299 "AuthToken": "abcdefg",
305 "CollectionBatchSize": 100000,
306 "CollectionBuffers": 1000,
307 "RequestTimeout": "30m",
308 "ManagementToken": "xyzzy",
309 "LostBlocksFile": "testfile"