Esempio n. 1
0
func TestNewWithUserConfigFileWithErrors(t *testing.T) {
	_, usrCfgFilePath := newConfigDirs("TestNewWithUserConfigFileWithErrors", t)
	gotil.WriteStringToFile(string(yamlConfig1), usrCfgFilePath)

	os.Chmod(usrCfgFilePath, 0000)
	New()
}
Esempio n. 2
0
// WritePidFile writes the current process ID to the REX-Ray PID file.
func WritePidFile(pid int) error {

	if pid < 0 {
		pid = os.Getpid()
	}

	return gotil.WriteStringToFile(fmt.Sprintf("%d", pid), PidFilePath())
}
Esempio n. 3
0
func TestNewWithGlobalConfigFileWithErrors(t *testing.T) {
	etcCfgFilePath, _ := newConfigDirs(
		"TestNewWithGlobalConfigFileWithErrors", t)

	t.Logf("etcCfgFilePath=%s", etcCfgFilePath)
	gotil.WriteStringToFile(string(yamlConfig1), etcCfgFilePath)

	os.Chmod(etcCfgFilePath, 0000)
	New()
}
Esempio n. 4
0
func TestReadPidFileWithErrors(t *testing.T) {
	newPrefixDir("TestWriteReadPidFile", t)

	var err error
	if _, err = ReadPidFile(); err == nil {
		t.Fatal("error expected in reading pid file")
	}

	gotil.WriteStringToFile("hello", PidFilePath())

	if _, err = ReadPidFile(); err == nil {
		t.Fatal("error expected in reading pid file")
	}
}
Esempio n. 5
0
func TestNewWithUserConfigFile(t *testing.T) {
	_, usrCfgFilePath := newConfigDirs("TestNewWithUserConfigFile", t)
	gotil.WriteStringToFile(string(yamlConfig1), usrCfgFilePath)

	c := New()

	assertString(t, c, "rexray.logLevel", "error")
	assertStorageDrivers(t, c)
	assertOsDrivers1(t, c)

	if err := c.ReadConfig(bytes.NewReader(yamlConfig2)); err != nil {
		t.Fatal(err)
	}

	assertString(t, c, "rexray.logLevel", "debug")
	assertStorageDrivers(t, c)
	assertOsDrivers2(t, c)
}
Esempio n. 6
0
func TestCopy(t *testing.T) {
	etcCfgFilePath, _ := newConfigDirs("TestCopy", t)
	wipeEnv()
	Register(testReg3())

	t.Logf("etcCfgFilePath=%s", etcCfgFilePath)
	gotil.WriteStringToFile(string(yamlConfig1), etcCfgFilePath)

	c1 := New()

	assertString(t, c1, "rexray.logLevel", "error")
	assertStorageDrivers(t, c1)
	assertOsDrivers1(t, c1)

	c2, _ := c1.Copy()

	assertString(t, c2, "rexray.logLevel", "error")
	assertStorageDrivers(t, c2)
	assertOsDrivers1(t, c2)

	assertConfigsEqual(c1, c2, t)
}
Esempio n. 7
0
File: util.go Progetto: akutz/rexray
// WriteSpecFile writes the current host address to the REX-Ray spec file.
func WriteSpecFile(host string) error {
	return gotil.WriteStringToFile(host, SpecFilePath())
}