コード例 #1
0
func TestMeasurements(t *testing.T) {
	binPath := "../../linux_backend/bin"
	rootFSPath := os.Getenv("WARDEN_TEST_ROOTFS")

	if rootFSPath == "" {
		log.Println("WARDEN_TEST_ROOTFS undefined; skipping")
		return
	}

	var err error

	tmpdir, err := ioutil.TempDir("", "warden-socket")
	if err != nil {
		log.Fatalln("failed to make dir for socker:", err)
	}

	wardenPath, err := gexec.Build("github.com/cloudfoundry-incubator/warden-linux", "-race")
	if err != nil {
		log.Fatalln("failed to compile warden-linux:", err)
	}

	runner, err = Runner.New(wardenPath, binPath, rootFSPath, "unix", filepath.Join(tmpdir, "warden.sock"))
	if err != nil {
		log.Fatalln("failed to create runner:", err)
	}

	RegisterFailHandler(Fail)
	RunSpecs(t, "Measurements Suite")

	err = runner.Stop()
	if err != nil {
		log.Fatalln("warden failed to stop:", err)
	}

	err = runner.TearDown()
	if err != nil {
		log.Fatalln("failed to tear down server:", err)
	}

	err = os.RemoveAll(tmpdir)
	if err != nil {
		log.Fatalln("failed to clean up socket dir:", err)
	}
}
コード例 #2
0
func TestLifecycle(t *testing.T) {
	binPath := "../../linux_backend/bin"
	rootFSPath := os.Getenv("WARDEN_TEST_ROOTFS")

	if rootFSPath == "" {
		log.Println("WARDEN_TEST_ROOTFS undefined; skipping")
		return
	}

	var tmpdir string

	BeforeSuite(func() {
		var err error

		tmpdir, err = ioutil.TempDir("", "warden-socket")
		Ω(err).ShouldNot(HaveOccurred())

		wardenPath, err := gexec.Build("github.com/cloudfoundry-incubator/warden-linux", "-race")
		Ω(err).ShouldNot(HaveOccurred())

		runner, err = Runner.New(wardenPath, binPath, rootFSPath, "unix", filepath.Join(tmpdir, "warden.sock"))
		Ω(err).ShouldNot(HaveOccurred())

		err = runner.Start()
		Ω(err).ShouldNot(HaveOccurred())

		client = runner.NewClient()
	})

	AfterSuite(func() {
		err := runner.Stop()
		Ω(err).ShouldNot(HaveOccurred())

		err = runner.TearDown()
		Ω(err).ShouldNot(HaveOccurred())

		err = os.RemoveAll(tmpdir)
		Ω(err).ShouldNot(HaveOccurred())
	})

	RegisterFailHandler(Fail)
	RunSpecs(t, "Lifecycle Suite")
}