Ejemplo n.º 1
0
	Expect(err).NotTo(HaveOccurred())
})

var _ = AfterSuite(func() {
	gexec.CleanupBuildArtifacts()
})

func verifyServerIsListening() error {
	_, err := net.Dial("tcp", serverAddress)
	return err
}

var _ = BeforeEach(func() {
	var err error

	serverSession, err = gexec.Start(exec.Command(pathToServerBinary), GinkgoWriter, GinkgoWriter)
	Expect(err).NotTo(HaveOccurred())

	Eventually(verifyServerIsListening).Should(Succeed())
})

var _ = AfterEach(func() {
	serverSession.Interrupt()
	Eventually(serverSession).Should(gexec.Exit())
})

func TestSystem(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "System Test Suite")
}
		// GinkgoParallelNode() necessary to avoid test pollution in parallel
		spaceID = fmt.Sprintf("some-space-id-%x", GinkgoParallelNode())
		networkID = spaceID
		containerID = fmt.Sprintf("some-container-id-%x", rand.Int())
		appID = fmt.Sprintf("some-app-id-%x", rand.Int())

		networkMapper := &network.FixedNetworkMapper{DefaultNetworkID: "default"}
		vni, err = networkMapper.GetVNI(spaceID)
		Expect(err).NotTo(HaveOccurred())

		sandboxName = fmt.Sprintf("vni-%d", vni)
	})

	AfterEach(func() {
		session.Interrupt()
		Eventually(session, DEFAULT_TIMEOUT).Should(gexec.Exit(0))
		Expect(containerRepo.Destroy(containerNamespace)).To(Succeed())
	})

	var serverIsAvailable = func() error {
		return VerifyTCPConnection(address)
	}

	Context("ducatid server restarts", func() {
		var (
			upSpec       models.CNIAddPayload
			downSpec     models.CNIDelPayload
			daemonClient *client.DaemonClient
			ipamResult   types.Result
		)
Ejemplo n.º 3
0
				ssh := exec.Command("ssh", sshArgv...)

				var err error
				sshStdin, err = ssh.StdinPipe()
				Ω(err).ShouldNot(HaveOccurred())

				sshSess, err = gexec.Start(
					ssh,
					gexec.NewPrefixedWriter("\x1b[32m[o]\x1b[0m\x1b[33m[ssh]\x1b[0m ", GinkgoWriter),
					gexec.NewPrefixedWriter("\x1b[91m[e]\x1b[0m\x1b[33m[ssh]\x1b[0m ", GinkgoWriter),
				)
				Ω(err).ShouldNot(HaveOccurred())
			})

			AfterEach(func() {
				sshSess.Interrupt().Wait(10 * time.Second)
			})

			Context("with a valid key", func() {
				BeforeEach(func() {
					sshArgv = append(sshArgv, "-i", userKey)
				})

				Context("when running register-worker", func() {
					BeforeEach(func() {
						sshArgv = append(sshArgv, "register-worker")
					})

					It("does not exit", func() {
						Consistently(sshSess, 1).ShouldNot(gexec.Exit())
					})