Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #98 core acceptance tests #101

Merged
merged 25 commits into from
Jan 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a68a207
Added initial tests for a CLIParser and the first acceptance test
reaandrew Jan 22, 2017
8eec5fd
Added a suite of tests for the command line covering plan usage and a…
reaandrew Jan 22, 2017
ca24d2f
Adding some debug in to try and catch this bug
reaandrew Jan 23, 2017
478db72
debugging for error on travis
reaandrew Jan 23, 2017
e047ac0
continue to debug
reaandrew Jan 23, 2017
395627b
debugging the events subscription
reaandrew Jan 23, 2017
a7d32e7
debugging the events published
reaandrew Jan 23, 2017
216cf04
Removing the cancel for now and letting the program end gracefully
reaandrew Jan 24, 2017
9f0515b
Adding more tests to the assertion parsers
reaandrew Jan 24, 2017
5a9552a
Changed the type of the Running Time property on ExecutionSummary
reaandrew Jan 25, 2017
124b6e3
Debugging the sync issue agagin
reaandrew Jan 25, 2017
b5753c2
Debugging
reaandrew Jan 25, 2017
beed8a0
Sleeping for now until further investigation into the sync problem
reaandrew Jan 27, 2017
9fc6660
Removing the test focus
reaandrew Jan 27, 2017
a547d93
Increasing the timing but doesn't appear to work
reaandrew Jan 27, 2017
b3a1b24
Replaced the use of telegraph with simple channels
reaandrew Jan 28, 2017
a4f3bbe
Merge branch 'develop' into issue_#95_core_acceptance_tests
reaandrew Jan 28, 2017
93a45b3
Returned the ExecutionSummary from all the tests and updated the impl…
reaandrew Jan 28, 2017
0acf902
Removing the 21
reaandrew Jan 28, 2017
ab74177
Delete a load of commented out code
reaandrew Jan 29, 2017
4564018
Adding failure case for empty assertion parser
reaandrew Jan 29, 2017
df98ff7
Adding failure case for exact assertion parser
reaandrew Jan 29, 2017
4df7382
Adding failure case for greater than assertion parser
reaandrew Jan 29, 2017
0043204
Adding failure case for greater than assertion parser
reaandrew Jan 29, 2017
26b475f
Added tests for the failure on parsing
reaandrew Jan 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 184 additions & 53 deletions Acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main_test
import (
"fmt"
"io/ioutil"
"math"
"net/http"
"regexp"

Expand All @@ -18,46 +19,203 @@ import (

var _ = Describe("Acceptance", func() {

It("Halts execution if a payload input file is not found", func() {
list := []string{
fmt.Sprintf(`%s -X POST -d '{"name":"talula"}'`, URLForTestServer("/success")),
fmt.Sprintf(`%s -X POST -d @missing-file.json`, URLForTestServer("/success")),
}
BeforeEach(func() {
TestServer.Clear()
factory := rizo.HTTPResponseFactory(func(w http.ResponseWriter) {
w.Header().Add("done", "1")
w.WriteHeader(http.StatusOK)
})

output, err := test.ExecuteList("./corcel", list)
Expect(err).ToNot(BeNil())
TestServer.Use(factory).For(rizo.RequestWithPath("/people"))
})

Expect(string(output)).To(ContainSubstring("Request body file not found: missing-file.json"))
AfterEach(func() {
TestServer.Clear()
})

It("Outputs a summary to STDOUT", func() {
Describe("Core Command Line Usage", func() {

Describe("Iterations", func() {

It("Plan Usage", func() {

var plan = fmt.Sprintf(`---
name: Some Plan
iterations: 5
random: false
workers: 1
waitTime: 0s
duration: 0s
jobs:
- name: Some Job
steps:
- name: Some Step
action:
type: HttpRequest
httpHeaders:
key: 1
method: GET
url: %s`, TestServer.CreateURL("/people"))

summary, err := test.ExecutePlanFromData(plan, "--summary")

Expect(err).To(BeNil())

Expect(summary.TotalRequests).To(Equal(float64(5)))
})

It("List Usage", func() {
list := []string{
fmt.Sprintf(`%s -X GET'`, TestServer.CreateURL("/people")),
}
summary, err := test.ExecuteList(list, "--summary", "--iterations", "5")
Expect(err).To(BeNil())

Expect(summary.TotalRequests).To(Equal(float64(5)))
})
})

Describe("Workers", func() {

It("Plan Usage", func() {

var plan = fmt.Sprintf(`---
name: Some Plan
iterations: 0
random: false
workers: 5
waitTime: 0s
duration: 0s
jobs:
- name: Some Job
steps:
- name: Some Step
action:
type: HttpRequest
httpHeaders:
key: 1
method: GET
url: %s`, TestServer.CreateURL("/people"))

summary, err := test.ExecutePlanFromData(plan, "--summary")

Expect(err).To(BeNil())

Expect(summary.TotalRequests).To(Equal(float64(5)))
})

It("List Usage", func() {
list := []string{
fmt.Sprintf(`%s -X GET'`, TestServer.CreateURL("/people")),
}
summary, err := test.ExecuteList(list, "--summary", "--workers", "5")
Expect(err).To(BeNil())

Expect(summary.TotalRequests).To(Equal(float64(5)))
})
})

Describe("Wait Time", func() {

It("Plan Usage", func() {

var plan = fmt.Sprintf(`---
name: Some Plan
iterations: 5
random: false
workers: 1
waitTime: 1s
duration: 0s
jobs:
- name: Some Job
steps:
- name: Some Step
action:
type: HttpRequest
httpHeaders:
key: 1
method: GET
url: %s`, TestServer.CreateURL("/people"))

summary, err := test.ExecutePlanFromData(plan, "--summary")

Expect(err).To(BeNil())

Expect(math.Floor(summary.RunningTime.Seconds())).To(Equal(float64(5)))
})

It("List Usage", func() {
list := []string{
fmt.Sprintf(`%s -X GET'`, TestServer.CreateURL("/people")),
}
summary, err := test.ExecuteList(list, "--summary", "--wait-time", "1s", "--iterations", "5")
Expect(err).To(BeNil())

Expect(math.Floor(summary.RunningTime.Seconds())).To(Equal(float64(5)))
})
})

Describe("Duration", func() {

It("Plan Usage", func() {

var plan = fmt.Sprintf(`---
name: Some Plan
iterations: 0
random: false
workers: 1
waitTime: 0s
duration: 5s
jobs:
- name: Some Job
steps:
- name: Some Step
action:
type: HttpRequest
httpHeaders:
key: 1
method: GET
url: %s`, TestServer.CreateURL("/people"))

summary, err := test.ExecutePlanFromData(plan, "--summary")

Expect(err).To(BeNil())

Expect(math.Floor(summary.RunningTime.Seconds())).To(Equal(float64(5)))
})

It("List Usage", func() {
list := []string{
fmt.Sprintf(`%s -X GET'`, TestServer.CreateURL("/people")),
}
summary, err := test.ExecuteList(list, "--summary", "--duration", "5s")
Expect(err).To(BeNil())

Expect(math.Floor(summary.RunningTime.Seconds())).To(Equal(float64(5)))
})
})
})

It("Halts execution if a payload input file is not found", func() {
list := []string{
fmt.Sprintf(`%s -X POST `, URLForTestServer("/error")),
fmt.Sprintf(`%s -X POST `, URLForTestServer("/success")),
fmt.Sprintf(`%s -X POST `, URLForTestServer("/error")),
fmt.Sprintf(`%s -X POST `, URLForTestServer("/success")),
fmt.Sprintf(`%s -X POST `, URLForTestServer("/error")),
fmt.Sprintf(`%s -X POST `, URLForTestServer("/success")),
fmt.Sprintf(`%s -X POST -d '{"name":"talula"}'`, URLForTestServer("/success")),
fmt.Sprintf(`%s -X POST -d @missing-file.json`, URLForTestServer("/success")),
}

TestServer.Use(rizo.HTTPResponseFactory(func(w http.ResponseWriter) {
w.WriteHeader(500)
})).For(rizo.RequestWithPath("/error"))

output, err := test.ExecuteList("./corcel", list, "--summary")
Expect(err).To(BeNil())
_, err := test.ExecuteList(list, "--summary")
Expect(err).ToNot(BeNil())

Expect(string(output)).To(ContainSubstring("Summary"))
Expect(fmt.Sprintf("%v", err)).To(ContainSubstring("Request body file not found: missing-file.json"))
})

It("Error non-http url in the urls file causes a run time exception #21", func() {
It("Error non-http url in the urls file causes a run time exception", func() {
list := []string{
fmt.Sprintf(`-Something`),
}

output, err := test.ExecuteList("./corcel", list)
_, err := test.ExecuteList(list, "--summary")
Expect(err).ToNot(BeNil())
Expect(string(output)).To(ContainSubstring(errormanager.LogMessageVaidURLs))
Expect(fmt.Sprintf("%v", err)).To(ContainSubstring(errormanager.LogMessageVaidURLs))
})

It("Issue - Should write out panics to a log file and not std out", func() {
Expand All @@ -72,7 +230,7 @@ var _ = Describe("Acceptance", func() {
output, err := test.ExecutePlanBuilder(planBuilder)
Expect(err).ToNot(BeNil())

Expect(string(output)).To(ContainSubstring("An unexpected error has occurred. The error has been logged to /tmp/"))
Expect(output).To(ContainSubstring("An unexpected error has occurred. The error has been logged to /tmp/"))

//Ensure that the file which was generated contains the error which caused the panic
r, _ := regexp.Compile(`/tmp/[\w\d-]+`)
Expand All @@ -82,31 +240,4 @@ var _ = Describe("Acceptance", func() {
Expect(err).To(BeNil())
Expect(string(data)).To(ContainSubstring("IPanicAction has caused this panic"))
})

Describe("Shell", func() {

Describe("run", func() {

PIt("setting iterations", func() {

})

PIt("setting duration", func() {

})

PIt("setting workers", func() {

})

PIt("setting plan", func() {

})

PIt("setting summary", func() {

})
})

})
})
Loading