ceph: remove DaemonType type

This type was a string already and was just making us doing string()
calls all the time to it's not worth it.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han
2020-04-01 09:08:18 +02:00
parent 7788901a88
commit 040193bb5a
21 changed files with 44 additions and 66 deletions
+1 -1
View File
@@ -506,7 +506,7 @@ func (c *daemonConfig) buildSocketPath() string {
func (c *daemonConfig) buildAdminSocketCommand() string {
command := "status"
if c.daemonType == string(config.MonType) {
if c.daemonType == config.MonType {
command = "mon_status"
}
+6 -10
View File
@@ -104,44 +104,40 @@ func TestCheckPodMemory(t *testing.T) {
}
func TestBuildAdminSocketCommand(t *testing.T) {
daemonType := string(config.OsdType)
c := getDaemonConfig(daemonType, "")
c := getDaemonConfig(config.OsdType, "")
command := c.buildAdminSocketCommand()
assert.Equal(t, "status", command)
c.daemonType = string(config.MonType)
c.daemonType = config.MonType
command = c.buildAdminSocketCommand()
assert.Equal(t, "mon_status", command)
}
func TestBuildSocketName(t *testing.T) {
daemonType := string(config.OsdType)
daemonID := "0"
c := getDaemonConfig(daemonType, daemonID)
c := getDaemonConfig(config.OsdType, daemonID)
socketName := c.buildSocketName()
assert.Equal(t, "ceph-osd.0.asok", socketName)
c.daemonType = string(config.MonType)
c.daemonType = config.MonType
c.daemonID = "a"
socketName = c.buildSocketName()
assert.Equal(t, "ceph-mon.a.asok", socketName)
}
func TestBuildSocketPath(t *testing.T) {
daemonType := string(config.OsdType)
daemonID := "0"
c := getDaemonConfig(daemonType, daemonID)
c := getDaemonConfig(config.OsdType, daemonID)
socketPath := c.buildSocketPath()
assert.Equal(t, "/run/ceph/ceph-osd.0.asok", socketPath)
}
func TestGenerateLivenessProbeExecDaemon(t *testing.T) {
daemonType := string(config.OsdType)
daemonID := "0"
probe := GenerateLivenessProbeExecDaemon(daemonType, daemonID)
probe := GenerateLivenessProbeExecDaemon(config.OsdType, daemonID)
expectedCommand := []string{"env",
"-i",
"sh",