Skip to content

Commit

Permalink
test: simplify running device manager tests
Browse files Browse the repository at this point in the history
Instead of having to run the test twice to get full coverage, the test
binary itself now contains these different test cases. This is
consistent with how other tests work and localizes the knowledge of
existing tests inside the test suite itself.
  • Loading branch information
pohly committed Nov 15, 2019
1 parent 0fa6fef commit a9e7136
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 7 additions & 8 deletions pkg/pmem-device-manager/pmd-lvm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,22 @@ const (
ModeDirect = "direct"
)

var mode string = ModeLVM

func TestMain(m *testing.M) {
RegisterFailHandler(Fail)

if deviceMode := os.Getenv("TEST_DEVICEMODE"); deviceMode == ModeDirect {
mode = deviceMode
}

os.Exit(m.Run())
}

func TestPmdLVM(t *testing.T) {
RunSpecs(t, fmt.Sprintf("PMEM Device manager Suite(Mode: %s)", mode))
RunSpecs(t, "PMEM Device manager Suite")
}

var _ = Describe("DeviceManager", func() {
Context(ModeLVM, func() { runTest(ModeLVM) })
Context(ModeDirect, func() { runTest(ModeDirect) })
})

func runTest(mode string) {
var dm PmemDeviceManager
var vg *testVGS
var cleanupList map[string]bool = map[string]bool{}
Expand Down Expand Up @@ -188,7 +187,7 @@ var _ = Describe("DeviceManager", func() {
Expect(err).Should(BeNil(), "DeleteDevice() is not idempotent")
})
// })
})
}

func precheck() {
if os.Geteuid() != 0 {
Expand Down
3 changes: 1 addition & 2 deletions test/test.make
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ run_dm_tests: start_test_vm
WORKER=$(shell grep ^exec `pwd`/_work/$(CLUSTER)/ssh.0 | rev | cut -f2 -d' ' | rev) && \
SSH_ARGS="$(shell grep ^exec `pwd`/_work/$(CLUSTER)/ssh.0 | cut -f3- -d' ' | rev | cut -f3- -d' ' | rev)" && \
scp $$SSH_ARGS `pwd`/_work/$(TEST_BINARY_NAME) $$WORKER:. && \
$(PWD)/_work/$(CLUSTER)/ssh.0 sudo env TEST_DEVICEMODE=lvm ./$(TEST_BINARY_NAME) -ginkgo.v && \
$(PWD)/_work/$(CLUSTER)/ssh.0 sudo env TEST_DEVICEMODE=direct ./$(TEST_BINARY_NAME) -ginkgo.v && \
$(PWD)/_work/$(CLUSTER)/ssh.0 sudo ./$(TEST_BINARY_NAME) -ginkgo.v && \
$(MAKE) stop


Expand Down

0 comments on commit a9e7136

Please sign in to comment.