1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: Apache-2.0
11 "github.com/ghodss/yaml"
12 check "gopkg.in/check.v1"
15 var _ = check.Suite(&ConfigSuite{})
17 type ConfigSuite struct{}
19 func (s *ConfigSuite) TestStringSetAsArray(c *check.C) {
21 yaml.Unmarshal([]byte(`
23 DisabledAPIs: [jobs.list]`), &cluster)
24 c.Check(len(cluster.API.DisabledAPIs), check.Equals, 1)
25 _, ok := cluster.API.DisabledAPIs["jobs.list"]
26 c.Check(ok, check.Equals, true)
29 func (s *ConfigSuite) TestInstanceTypesAsHash(c *check.C) {
31 yaml.Unmarshal([]byte("InstanceTypes:\n foo:\n ProviderType: bar\n"), &cluster)
32 c.Check(len(cluster.InstanceTypes), check.Equals, 1)
33 c.Check(cluster.InstanceTypes["foo"].Name, check.Equals, "foo")
34 c.Check(cluster.InstanceTypes["foo"].ProviderType, check.Equals, "bar")
37 func (s *ConfigSuite) TestInstanceTypeSize(c *check.C) {
39 err := yaml.Unmarshal([]byte("Name: foo\nIncludedScratch: 4GB\nRAM: 4GiB\n"), &it)
40 c.Check(err, check.IsNil)
41 c.Check(int64(it.IncludedScratch), check.Equals, int64(4000000000))
42 c.Check(int64(it.RAM), check.Equals, int64(4294967296))
45 func (s *ConfigSuite) TestInstanceTypeFixup(c *check.C) {
46 for _, confdata := range []string{
47 // Current format: map of entries
48 `{foo4: {IncludedScratch: 4GB}, foo8: {ProviderType: foo_8, AddedScratch: 8GB}}`,
51 var itm InstanceTypeMap
52 err := yaml.Unmarshal([]byte(confdata), &itm)
53 c.Check(err, check.IsNil)
55 c.Check(itm["foo4"].Name, check.Equals, "foo4")
56 c.Check(itm["foo4"].ProviderType, check.Equals, "foo4")
57 c.Check(itm["foo4"].Scratch, check.Equals, ByteSize(4000000000))
58 c.Check(itm["foo4"].AddedScratch, check.Equals, ByteSize(0))
59 c.Check(itm["foo4"].IncludedScratch, check.Equals, ByteSize(4000000000))
61 c.Check(itm["foo8"].Name, check.Equals, "foo8")
62 c.Check(itm["foo8"].ProviderType, check.Equals, "foo_8")
63 c.Check(itm["foo8"].Scratch, check.Equals, ByteSize(8000000000))
64 c.Check(itm["foo8"].AddedScratch, check.Equals, ByteSize(8000000000))
65 c.Check(itm["foo8"].IncludedScratch, check.Equals, ByteSize(0))
69 func (s *ConfigSuite) TestURLTrailingSlash(c *check.C) {
71 json.Unmarshal([]byte(`{"https://foo.example": true}`), &a)
72 json.Unmarshal([]byte(`{"https://foo.example/": true}`), &b)
73 c.Check(a, check.DeepEquals, b)
76 func (s *ConfigSuite) TestTLSVersion(c *check.C) {
80 err := json.Unmarshal([]byte(`{"Version": 1.0}`), &v)
81 c.Check(err, check.IsNil)
82 c.Check(v.Version, check.Equals, TLSVersion(tls.VersionTLS10))
84 err = json.Unmarshal([]byte(`{"Version": "1.3"}`), &v)
85 c.Check(err, check.IsNil)
86 c.Check(v.Version, check.Equals, TLSVersion(tls.VersionTLS13))
88 err = json.Unmarshal([]byte(`{"Version": "1.345"}`), &v)
89 c.Check(err, check.NotNil)