-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_test.go
79 lines (69 loc) · 2.02 KB
/
service_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package mongo_test
import (
"fmt"
"os"
"path/filepath"
"time"
"github.com/juju/clock/testclock"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/mongo"
coretesting "github.com/juju/juju/testing"
)
type serviceSuite struct {
coretesting.BaseSuite
}
var _ = gc.Suite(&serviceSuite{})
func (s *serviceSuite) TestNewConfSnap(c *gc.C) {
dataDir := "/var/lib/juju"
dbDir := dataDir + "/db"
logPath := dataDir + "/logs/mongodb.log"
confArgs := mongo.ConfigArgs{
Clock: testclock.NewClock(time.Now()),
DataDir: dataDir,
DBDir: dbDir,
Port: 12345,
OplogSizeMB: 10,
IPv6: true,
LogPath: logPath,
ReplicaSet: "juju",
MemoryProfile: mongo.MemoryProfileLow,
PEMKeyFile: "/var/lib/juju/server.pem",
PEMKeyPassword: "ignored",
AuthKeyFile: "/var/lib/juju/shared-secret",
Syslog: true,
Quiet: true,
TLSMode: "requireTLS",
WiredTigerCacheSizeGB: 0.25,
BindToAllIP: true,
}
confFile := filepath.Join(c.MkDir(), "conf")
err := mongo.WriteConfig(confArgs, confFile)
c.Assert(err, jc.ErrorIsNil)
contents, err := os.ReadFile(confFile)
c.Assert(err, jc.ErrorIsNil)
expected := fmt.Sprintf(`
# WARNING
# autogenerated by juju on %s
# manual changes to this file are likely to be overwritten
auth = true
bind_ip_all = true
dbpath = %s/db
ipv6 = true
journal = true
keyFile = %s/shared-secret
logpath = %s/logs/mongodb.log
oplogSize = 10
port = 12345
quiet = true
replSet = juju
storageEngine = wiredTiger
syslog = true
tlsCertificateKeyFile = %s/server.pem
tlsCertificateKeyFilePassword=ignored
tlsMode = requireTLS
wiredTigerCacheSizeGB = 0.25`[1:], confArgs.Clock.Now().UTC().Format(time.RFC822), dataDir, dataDir, dataDir, dataDir)
c.Assert(string(contents), jc.DeepEquals, expected)
}