-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_test.go
90 lines (75 loc) · 2.14 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
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2015 Canonical Ltd.
// Licensed under the AGPLv3, see LICENCE file for details.
package mongo_test
import (
"strings"
jc "github.com/juju/testing/checkers"
gc "gopkg.in/check.v1"
"github.com/juju/juju/mongo"
"github.com/juju/juju/service/common"
svctesting "github.com/juju/juju/service/common/testing"
coretesting "github.com/juju/juju/testing"
)
type serviceSuite struct {
coretesting.BaseSuite
}
var _ = gc.Suite(&serviceSuite{})
func (s *serviceSuite) TestNewConf(c *gc.C) {
dataDir := "/var/lib/juju"
dbDir := dataDir + "/db"
mongodPath := "/mgo/bin/mongod"
mongodVersion := mongo.Mongo24
port := 12345
oplogSizeMB := 10
conf := mongo.NewConf(mongo.ConfigArgs{
DataDir: dataDir,
DBDir: dbDir,
MongoPath: mongodPath,
Port: port,
OplogSizeMB: oplogSizeMB,
WantNUMACtl: false,
Version: mongodVersion,
Auth: true,
IPv6: true,
})
expected := common.Conf{
Desc: "juju state database",
Limit: map[string]int{
"nofile": 65000,
"nproc": 20000,
},
Timeout: 300,
ExecStart: "/mgo/bin/mongod" +
" --dbpath '/var/lib/juju/db'" +
" --sslOnNormalPorts" +
" --sslPEMKeyFile '/var/lib/juju/server.pem'" +
" --sslPEMKeyPassword=ignored" +
" --port 12345" +
" --syslog" +
" --journal" +
" --replSet juju" +
" --quiet" +
" --oplogSize 10" +
" --ipv6" +
" --auth" +
" --keyFile '/var/lib/juju/shared-secret'" +
" --noprealloc" +
" --smallfiles",
}
c.Check(conf, jc.DeepEquals, expected)
c.Check(strings.Fields(conf.ExecStart), jc.DeepEquals, strings.Fields(expected.ExecStart))
}
func (s *serviceSuite) TestIsServiceInstalledWhenInstalled(c *gc.C) {
svcName := mongo.ServiceName
svcData := svctesting.NewFakeServiceData(svcName)
mongo.PatchService(s.PatchValue, svcData)
isInstalled, err := mongo.IsServiceInstalled()
c.Assert(err, jc.ErrorIsNil)
c.Assert(isInstalled, jc.IsTrue)
}
func (s *serviceSuite) TestIsServiceInstalledWhenNotInstalled(c *gc.C) {
mongo.PatchService(s.PatchValue, svctesting.NewFakeServiceData())
isInstalled, err := mongo.IsServiceInstalled()
c.Assert(err, jc.ErrorIsNil)
c.Assert(isInstalled, jc.IsFalse)
}