Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

registry/rpc: re-enable error handling after NewSystemdUnitManage #1693

Merged
merged 2 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions registry/rpc/registrymux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package rpc
import (
"io/ioutil"
"os"
"syscall"
"testing"

etcd "github.com/coreos/etcd/client"
Expand Down Expand Up @@ -89,19 +90,21 @@ func TestRegistryMuxUnitManagement(t *testing.T) {
}
defer os.RemoveAll(uDir)

if syscall.Geteuid() != 0 {
t.Skipf("non-root user cannot call systemd unit manager. skip.")
}
if info, err := os.Stat("/run/systemd/system"); err != nil || !info.IsDir() {
t.Skipf("systemd is not available. skip.")
}

state := &machine.MachineState{
ID: "id",
PublicIP: "127.0.0.1",
Metadata: make(map[string]string, 0),
}
mgr, err := systemd.NewSystemdUnitManager(uDir, false)
if err != nil {
// NOTE: ideally we should fail with t.Fatalf(), but then it would always
// fail on travis CI, because apparently systemd dbus socket is not
// available there. So let's just skip the test for now.
// In the long run, we should find a way to test it correctly on travis.
// - dpark 20160812
t.Skipf("unexpected error creating systemd unit manager: %v", err)
t.Fatalf("unexpected error creating systemd unit manager: %v", err)
}

mach := machine.NewCoreOSMachine(*state, mgr)
Expand Down
9 changes: 8 additions & 1 deletion ssh/known_hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"io/ioutil"
"net"
"os"
"runtime"
"strconv"
"syscall"
"testing"
Expand Down Expand Up @@ -165,7 +166,13 @@ func TestWrongHostKeyFile(t *testing.T) {
// If run as root, drop privileges temporarily
if id := syscall.Geteuid(); id == 0 {
if err := syscall.Setuid(12345); err != nil {
t.Fatalf("error setting uid: %v", err)
if runtime.GOOS == "linux" {
// On Linux syscall.Setuid is not supported, so we should not fail
// the test, but just skip for now. - dpark 20161021
t.Skipf("error setting uid: %v", err)
} else {
t.Fatalf("error setting uid: %v", err)
}
}
defer syscall.Setuid(id)
}
Expand Down