mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-24 11:55:40 +00:00
65aaa607ab
Change made by: - running "gvt fetch" on each of the packages mentioned in Godeps/Godeps.json - `rm -rf Godeps` - tweaking the build scripts to not mention Godeps - tweaking the build scripts to test `./lib/...`, `./cmd/...` explicitly (to avoid testing vendor) - tweaking the build scripts to not juggle GOPATH for Godeps and instead set GO15VENDOREXPERIMENT. This also results in some updated packages at the same time I bet. Building with Go 1.3 and 1.4 still *works* but won't use our vendored dependencies - the user needs to have the actual packages in their GOPATH then, which they'll get with a normal "go get". Building with Go 1.6+ will get our vendored dependencies by default even when not using our build script, which is nice. By doing this we gain some freedom in that we can pick and choose manually what to include in vendor, as it's not based on just dependency analysis of our own code. This is also a risk as we might pick up dependencies we are unaware of, as the build may work locally with those packages present in GOPATH. On the other hand the build server will detect this as it has no packages in it's GOPATH beyond what is included in the repo. Recommended tool to manage dependencies is github.com/FiloSottile/gvt.
179 lines
6.9 KiB
Go
179 lines
6.9 KiB
Go
package integration_test
|
|
|
|
import (
|
|
"strings"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
. "github.com/onsi/gomega"
|
|
"github.com/onsi/gomega/gexec"
|
|
)
|
|
|
|
var _ = Describe("SuiteSetup", func() {
|
|
var pathToTest string
|
|
|
|
Context("when the BeforeSuite and AfterSuite pass", func() {
|
|
BeforeEach(func() {
|
|
pathToTest = tmpPath("suite_setup")
|
|
copyIn("passing_suite_setup", pathToTest)
|
|
})
|
|
|
|
It("should run the BeforeSuite once, then run all the tests", func() {
|
|
session := startGinkgo(pathToTest, "--noColor")
|
|
Eventually(session).Should(gexec.Exit(0))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
|
|
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
|
|
})
|
|
|
|
It("should run the BeforeSuite once per parallel node, then run all the tests", func() {
|
|
session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
|
|
Eventually(session).Should(gexec.Exit(0))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
|
|
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
|
|
})
|
|
})
|
|
|
|
Context("when the BeforeSuite fails", func() {
|
|
BeforeEach(func() {
|
|
pathToTest = tmpPath("suite_setup")
|
|
copyIn("failing_before_suite", pathToTest)
|
|
})
|
|
|
|
It("should run the BeforeSuite once, none of the tests, but it should run the AfterSuite", func() {
|
|
session := startGinkgo(pathToTest, "--noColor")
|
|
Eventually(session).Should(gexec.Exit(1))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
|
|
Ω(strings.Count(output, "Test Panicked")).Should(Equal(1))
|
|
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
|
|
Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
|
|
})
|
|
|
|
It("should run the BeforeSuite once per parallel node, none of the tests, but it should run the AfterSuite for each node", func() {
|
|
session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
|
|
Eventually(session).Should(gexec.Exit(1))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
|
|
Ω(strings.Count(output, "Test Panicked")).Should(Equal(2))
|
|
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
|
|
Ω(output).ShouldNot(ContainSubstring("NEVER SEE THIS"))
|
|
})
|
|
})
|
|
|
|
Context("when the AfterSuite fails", func() {
|
|
BeforeEach(func() {
|
|
pathToTest = tmpPath("suite_setup")
|
|
copyIn("failing_after_suite", pathToTest)
|
|
})
|
|
|
|
It("should run the BeforeSuite once, none of the tests, but it should run the AfterSuite", func() {
|
|
session := startGinkgo(pathToTest, "--noColor")
|
|
Eventually(session).Should(gexec.Exit(1))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(1))
|
|
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(1))
|
|
Ω(strings.Count(output, "Test Panicked")).Should(Equal(1))
|
|
Ω(strings.Count(output, "A TEST")).Should(Equal(2))
|
|
})
|
|
|
|
It("should run the BeforeSuite once per parallel node, none of the tests, but it should run the AfterSuite for each node", func() {
|
|
session := startGinkgo(pathToTest, "--noColor", "--nodes=2")
|
|
Eventually(session).Should(gexec.Exit(1))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(strings.Count(output, "BEFORE SUITE")).Should(Equal(2))
|
|
Ω(strings.Count(output, "AFTER SUITE")).Should(Equal(2))
|
|
Ω(strings.Count(output, "Test Panicked")).Should(Equal(2))
|
|
Ω(strings.Count(output, "A TEST")).Should(Equal(2))
|
|
})
|
|
})
|
|
|
|
Context("With passing synchronized before and after suites", func() {
|
|
BeforeEach(func() {
|
|
pathToTest = tmpPath("suite_setup")
|
|
copyIn("synchronized_setup_tests", pathToTest)
|
|
})
|
|
|
|
Context("when run with one node", func() {
|
|
It("should do all the work on that one node", func() {
|
|
session := startGinkgo(pathToTest, "--noColor")
|
|
Eventually(session).Should(gexec.Exit(0))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(output).Should(ContainSubstring("BEFORE_A_1\nBEFORE_B_1: DATA"))
|
|
Ω(output).Should(ContainSubstring("AFTER_A_1\nAFTER_B_1"))
|
|
})
|
|
})
|
|
|
|
Context("when run across multiple nodes", func() {
|
|
It("should run the first BeforeSuite function (BEFORE_A) on node 1, the second (BEFORE_B) on all the nodes, the first AfterSuite (AFTER_A) on all the nodes, and then the second (AFTER_B) on Node 1 *after* everything else is finished", func() {
|
|
session := startGinkgo(pathToTest, "--noColor", "--nodes=3")
|
|
Eventually(session).Should(gexec.Exit(0))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(output).Should(ContainSubstring("BEFORE_A_1"))
|
|
Ω(output).Should(ContainSubstring("BEFORE_B_1: DATA"))
|
|
Ω(output).Should(ContainSubstring("BEFORE_B_2: DATA"))
|
|
Ω(output).Should(ContainSubstring("BEFORE_B_3: DATA"))
|
|
|
|
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_2"))
|
|
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_3"))
|
|
|
|
Ω(output).Should(ContainSubstring("AFTER_A_1"))
|
|
Ω(output).Should(ContainSubstring("AFTER_A_2"))
|
|
Ω(output).Should(ContainSubstring("AFTER_A_3"))
|
|
Ω(output).Should(ContainSubstring("AFTER_B_1"))
|
|
|
|
Ω(output).ShouldNot(ContainSubstring("AFTER_B_2"))
|
|
Ω(output).ShouldNot(ContainSubstring("AFTER_B_3"))
|
|
})
|
|
})
|
|
|
|
Context("when streaming across multiple nodes", func() {
|
|
It("should run the first BeforeSuite function (BEFORE_A) on node 1, the second (BEFORE_B) on all the nodes, the first AfterSuite (AFTER_A) on all the nodes, and then the second (AFTER_B) on Node 1 *after* everything else is finished", func() {
|
|
session := startGinkgo(pathToTest, "--noColor", "--nodes=3", "--stream")
|
|
Eventually(session).Should(gexec.Exit(0))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(output).Should(ContainSubstring("[1] BEFORE_A_1"))
|
|
Ω(output).Should(ContainSubstring("[1] BEFORE_B_1: DATA"))
|
|
Ω(output).Should(ContainSubstring("[2] BEFORE_B_2: DATA"))
|
|
Ω(output).Should(ContainSubstring("[3] BEFORE_B_3: DATA"))
|
|
|
|
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_2"))
|
|
Ω(output).ShouldNot(ContainSubstring("BEFORE_A_3"))
|
|
|
|
Ω(output).Should(ContainSubstring("[1] AFTER_A_1"))
|
|
Ω(output).Should(ContainSubstring("[2] AFTER_A_2"))
|
|
Ω(output).Should(ContainSubstring("[3] AFTER_A_3"))
|
|
Ω(output).Should(ContainSubstring("[1] AFTER_B_1"))
|
|
|
|
Ω(output).ShouldNot(ContainSubstring("AFTER_B_2"))
|
|
Ω(output).ShouldNot(ContainSubstring("AFTER_B_3"))
|
|
})
|
|
})
|
|
})
|
|
|
|
Context("With a failing synchronized before suite", func() {
|
|
BeforeEach(func() {
|
|
pathToTest = tmpPath("suite_setup")
|
|
copyIn("exiting_synchronized_setup_tests", pathToTest)
|
|
})
|
|
|
|
It("should fail and let the user know that node 1 disappeared prematurely", func() {
|
|
session := startGinkgo(pathToTest, "--noColor", "--nodes=3")
|
|
Eventually(session).Should(gexec.Exit(1))
|
|
output := string(session.Out.Contents())
|
|
|
|
Ω(output).Should(ContainSubstring("Node 1 disappeared before completing BeforeSuite"))
|
|
Ω(output).Should(ContainSubstring("Ginkgo timed out waiting for all parallel nodes to report back!"))
|
|
})
|
|
})
|
|
})
|