/
cleanup.go
54 lines (45 loc) · 1.38 KB
/
cleanup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package mtest
import (
"os"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)
// TestCleanup tests -force option test
func TestCleanup() {
It("should remove remaining resources and launch placemat", func() {
var session *gexec.Session
By("running placemat", func() {
session = runPlacemat(clusterYAML, "-force")
err := prepareSSHClients(node1, node2)
Expect(err).To(Succeed())
})
By("checking that socket files exist on a host", func() {
_, err := os.Stat("/tmp/node1/swtpm.socket")
Expect(err).NotTo(HaveOccurred())
_, err = os.Stat("/tmp/node2/swtpm.socket")
Expect(err).NotTo(HaveOccurred())
})
By("checking that a device file exists on guests", func() {
execSafeAt(node1, "test", "-c", "/dev/tpm0")
execSafeAt(node2, "test", "-c", "/dev/tpm0")
})
By("killing placemat process", func() {
killPlacemat(session)
Eventually(session.Exited).Should(BeClosed())
})
By("running placemat without -force option", func() {
session = runPlacemat(clusterYAML)
Eventually(session.Exited).Should(BeClosed())
})
By("running placemat with -force option", func() {
session = runPlacemat(clusterYAML, "-force")
err := prepareSSHClients(node1, node2)
Expect(err).To(Succeed())
})
By("terminating placemat", func() {
terminatePlacemat(session)
Eventually(session.Exited).Should(BeClosed())
})
})
}