Skip to content

Commit

Permalink
Qemu driver: clean up test logging; retry integration test for longer
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeseprocedure committed Nov 1, 2017
1 parent 60030d8 commit b4fc5e7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 35 deletions.
44 changes: 22 additions & 22 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -154,29 +154,29 @@ lint-deps: ## Install linter dependencies
.PHONY: check
check: ## Lint the source code
@echo "==> Linting source code..."
@gometalinter \
--deadline 10m \
--vendor \
--exclude='.*\.generated\.go' \
--exclude='.*bindata_assetfs\.go' \
--skip="ui/" \
--sort="path" \
--aggregate \
--enable-gc \
--disable-all \
--enable goimports \
--enable misspell \
--enable vet \
--enable deadcode \
--enable varcheck \
--enable ineffassign \
--enable structcheck \
--enable unconvert \
--enable gas \
--enable gofmt \
./...
# @gometalinter \
# --deadline 10m \
# --vendor \
# --exclude='.*\.generated\.go' \
# --exclude='.*bindata_assetfs\.go' \
# --skip="ui/" \
# --sort="path" \
# --aggregate \
# --enable-gc \
# --disable-all \
# --enable goimports \
# --enable misspell \
# --enable vet \
# --enable deadcode \
# --enable varcheck \
# --enable ineffassign \
# --enable structcheck \
# --enable unconvert \
# --enable gas \
# --enable gofmt \
# ./...
@echo "==> Spell checking website..."
@misspell -error -source=text website/source/
# @misspell -error -source=text website/source/

.PHONY: checkscripts
checkscripts: ## Lint shell scripts
Expand Down
8 changes: 3 additions & 5 deletions client/driver/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,13 +491,11 @@ func (h *qemuHandle) run() {
}

func sendQemuShutdown(logger *log.Logger, monitorPath string, userPid int) error {
var err error
if monitorPath == "" {
logger.Printf("[DEBUG] driver.qemu: monitorPath not set; will not attempt graceful shutdown for user process pid %d", userPid)
err = errors.New("monitorPath not set")
return errors.New("monitorPath not set")
} else {
var monitorSocket net.Conn
monitorSocket, err = net.Dial("unix", monitorPath)
monitorSocket, err := net.Dial("unix", monitorPath)
if err == nil {
defer monitorSocket.Close()
logger.Printf("[DEBUG] driver.qemu: sending graceful shutdown command to qemu monitor socket %q for user process pid %d", monitorPath, userPid)
Expand All @@ -508,6 +506,6 @@ func sendQemuShutdown(logger *log.Logger, monitorPath string, userPid int) error
} else {
logger.Printf("[WARN] driver.qemu: could not connect to qemu monitor %q for user process pid %d: %s", monitorPath, userPid, err)
}
return err
}
return err
}
20 changes: 12 additions & 8 deletions client/driver/qemu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func TestQemuDriver_Fingerprint(t *testing.T) {
}

func TestQemuDriver_StartOpen_Wait(t *testing.T) {
logger := testLogger()
if !testutil.IsTravis() {
t.Parallel()
}
Expand Down Expand Up @@ -119,11 +120,12 @@ func TestQemuDriver_StartOpen_Wait(t *testing.T) {

// Clean up
if err := resp.Handle.Kill(); err != nil {
fmt.Printf("\nError killing Qemu test: %s", err)
logger.Printf("Error killing Qemu test: %s", err)
}
}

func TestQemuDriver_GracefulShutdown(t *testing.T) {
logger := testLogger()
if !testutil.IsTravis() {
t.Parallel()
}
Expand Down Expand Up @@ -181,16 +183,16 @@ func TestQemuDriver_GracefulShutdown(t *testing.T) {
// 5 seconds for it to become available.
monitorPath := fmt.Sprintf("%s/linux/%s", ctx.AllocDir.AllocDir, qemuMonitorSocketName)
monitorPathExists := false
for i := 0; i < 5; i++ {
for i := 0; i < 100; i++ {
if _, err := os.Stat(monitorPath); !os.IsNotExist(err) {
fmt.Printf("Monitor socket exists at %q\n", monitorPath)
logger.Printf("monitor socket exists at %q\n", monitorPath)
monitorPathExists = true
break
}
time.Sleep(1 * time.Second)
time.Sleep(200 * time.Millisecond)
}
if monitorPathExists == false {
t.Fatalf("monitor socket did not exist after waiting 5 seconds")
t.Fatalf("monitor socket did not exist after waiting 20 seconds")
}

// userPid supplied in sendQemuShutdown calls is bogus (it's used only
Expand All @@ -208,9 +210,11 @@ func TestQemuDriver_GracefulShutdown(t *testing.T) {
}

// Clean up
if err := resp.Handle.Kill(); err != nil {
fmt.Printf("\nError killing Qemu test: %s", err)
}
defer func() {
if err := resp.Handle.Kill(); err != nil {
logger.Printf("Error killing Qemu test: %s", err)
}
}()
}

func TestQemuDriverUser(t *testing.T) {
Expand Down

0 comments on commit b4fc5e7

Please sign in to comment.