Skip to content

Commit

Permalink
only show 'SLOW TEST' when case takes >= 90% of scaled timeout time
Browse files Browse the repository at this point in the history
  • Loading branch information
Setup committed Nov 2, 2020
1 parent df7e7c7 commit c3ed0b8
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
9 changes: 9 additions & 0 deletions integration/fixtures/short_sleep_spec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
config: sleep.yml
enclosed_in_input: { name: this }
cases:
- when: it is called
it:
exits: 0
params:
DURATION: 6
2 changes: 2 additions & 0 deletions integration/integration_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
. "github.com/onsi/gomega"
)

Expand All @@ -16,6 +17,7 @@ func init() {
}

func TestIntegration(t *testing.T) {
config.DefaultReporterConfig.SlowSpecThreshold = 60.0
if targetArg == "" {
log.Fatal("--target argument must be provided")
}
Expand Down
10 changes: 10 additions & 0 deletions integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ var _ = Describe("running ironbird", func() {
})
})

Describe("slow specs", func() {
When("a test takes 6 seconds", func() {
It("does not print Ginkgo's warning about slow specs", func() {
session := invoke("--specs", "fixtures/short_sleep_spec.yml")
Eventually(session, 1*time.Minute).Should(Exit(0))
Expect(session).ToNot(Say("SLOW TEST"))
})
})
})

Describe("testing task output", func() {
It("works", func() {
session := invoke("--specs", "fixtures/echo_spec.yml")
Expand Down
13 changes: 9 additions & 4 deletions ironbird_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import (
"gopkg.in/yaml.v2"

. "github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
. "github.com/onsi/gomega"
)

const defaultTimeout = "20s"
const defaultTimeout = time.Second * time.Duration(20)

var specs []*ironbird.TaskTestSuite

Expand All @@ -32,9 +33,6 @@ func init() {
}

func TestIronbird(t *testing.T) {
RegisterFailHandler(Fail)
specFiles := strings.Split(specsArg, ",")

if specsArg == "" {
log.Fatal("--specs must be provided")
}
Expand All @@ -47,9 +45,16 @@ func TestIronbird(t *testing.T) {
log.Fatal("--timeout-factor must be >= 1")
}

modifier := .9
slowSpecThreshold := time.Duration(defaultTimeout.Seconds()*float64(timeoutFactorArg)*modifier) * time.Second
config.DefaultReporterConfig.SlowSpecThreshold = slowSpecThreshold.Seconds()

specFiles := strings.Split(specsArg, ",")
for _, specFile := range specFiles {
loadSpec(specFile)
}

RegisterFailHandler(Fail)
RunSpecs(t, "Ironbird: "+specsArg)
}

Expand Down
9 changes: 4 additions & 5 deletions ironbird_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,11 @@ var _ = Describe("", func() {

var session *Session
It(fmt.Sprintf("exits %d", specCase.It.Exits), func() {
within := specCase.Within
if within == "" {
within = defaultTimeout
var timeout = defaultTimeout
if specCase.Within != "" {
timeout, err = time.ParseDuration(specCase.Within)
Expect(err).ToNot(HaveOccurred())
}
timeout, err := time.ParseDuration(within)
Expect(err).ToNot(HaveOccurred())
timeout = timeout * time.Duration(timeoutFactorArg)
session = FlyExecute(targetArg, spec.SpecDir, spec.Config, specCase.Params, inputDirs, outputDirs, timeout)

Expand Down

0 comments on commit c3ed0b8

Please sign in to comment.