vdobler / ht Goto Github PK
View Code? Open in Web Editor NEWHttp Testing made easy
License: BSD 3-Clause "New" or "Revised" License
Http Testing made easy
License: BSD 3-Clause "New" or "Revised" License
2016/02/26 14:08:10 ERROR failed preparing request: parse https://localhost:9002{{PRODUCTURL}}: invalid character "{" in host name ["xxxx"]
2016/02/26 14:08:10 Suite "xxxx", cannot prepare main test "xxxx": failed preparing request: parse https://localhost:9002{{PRODUCTURL}}: invalid character "{" in host name
Version affected:
$ ~/code/ht/ht_windows.exe version
ht version v1.0.0beta1
and also linux version:
ht version v0.9.0
create test with following parameters:
Request: {
URL: "{{FRONTEND}}{{PRODUCTURL}}",
},
Request: {
URL: "{{FRONTEND}}/.{{PRODUCTURL}}",
},
Use case: I would like to test if an ecommerce website has between Friday and Saturday for certain URLs (products) new prices and from Sunday on restored the old prices. Those prices are in the product listing and on the product detail page, etc.
If the tests fail I got notified via email, slack, twitter, carrier pigeon ...
The old command to execute such a test:
$ ht_darwin exec -output ./system-integration/reports/ -Dfile ./system-integration/env/local.json ./system-integration/product_listing/...
The new command could be for example
$ ht_darwin cron -config mycron.hjson -Dfile ./system-integration/env/local.json &
Starts ht_darwin in the background and keeps it running until killed or handled via supervisord.
The mycron.hjson
contains the cron expression when to execute which test suite, a path to the test suite)
For example:
{
"Tests": [
{
"Name": "cron test new prices",
"CronExpression": "0 2 * * 5,6",
"Suite": "./system-integration/product_listing/...",
"Variables": {
"SKU_321654987_PRICE": 324.45,
},
"report": ["email1","slackA"]
},
{
"Name": "cron test old prices",
"CronExpression": "0 2 * * 7",
"Suite": "./system-integration/product_listing/...",
"Variables": {
"SKU_321654987_PRICE": 399.95,
},
"report": "email2",
},
],
"email1": {
"type": "email",
"smtp": "smtp.gmail.com",
"user": "hans",
"password": "uhu34hifhqief",
},
"email2": {
"type": "email",
"smtp": "smtp.gmail.com",
"user": "hans",
"password": "uhu34hifhqief",
},
"slackA": {
"type": "slack",
"TOKEN": "30205ead7bbe0b88c56d4005edb8ceff"
},
}
Might there be another way to achieve this, an easier via e.g. Unix command line tools?
Any other ideas or just crap?
My program of two files:
package main
import (
"net/http"
"time"
"github.com/vdobler/ht/ht"
)
var page01 = &ht.Test{
Name: "Load page01 with a GET request",
Request: ht.Request{
Method: "GET",
URL: "{{PROTOCOL}}://{{HOST}}/page01.html",
Header: http.Header{
"Accept": []string{"text/html"},
"Accept-Encoding": []string{"gzip, deflate, br"},
},
Timeout: 1 * time.Second,
},
Checks: ht.CheckList{
ht.StatusCode{Expect: 200},
&ht.Header{
Header: "Etag",
Condition: ht.Condition{
Min: 10}},
&ht.None{
Of: ht.CheckList{
&ht.HTMLContains{
Text: []string{"<esi:"},
}}},
&ht.Body{
Contains: "demo-store.shop/autumn-pullie.html",
Count: 1,
},
},
}
package main
import (
"os"
"runtime"
"github.com/vdobler/ht/cookiejar"
"github.com/vdobler/ht/ht"
)
func main() {
jar, err := cookiejar.New(&cookiejar.Options{})
if err != nil {
panic(err)
}
c := ht.Collection{
Tests: []*ht.Test{
page01,
},
}
if err := c.ExecuteConcurrent(runtime.NumCPU(), jar); err != nil {
panic(err)
}
if c.Error != nil {
panic(c.Error)
}
for _, test := range c.Tests {
if err := test.PrintReport(os.Stdout); err != nil {
panic(err)
}
}
}
Generates this error message:
$ go run ht/*.go
panic: malformed check: expected selector, found EOF instead
goroutine 1 [running]:
main.main()
/Users/xxxxxx/src/github.com/SchumacherFM/caddyesi/ht/main.go:22 +0x296
exit status 2
Which check? Where? Would love to see a bit of more verbosity.
I know I have those programs not installed ... but I have a suggestion:
Check if they are installed, and if not skip the test with a simple message:
if false == binariesInstalled() {
t.Skip("phantomjs not found, skipping ...")
}
So am I'm able to run the test suite and see if it all compiles but in-deeper testing is for you.
$ go test ./...
? github.com/vdobler/ht/cmd/ht [no test files]
ok github.com/vdobler/ht/cookiejar 0.013s
ok github.com/vdobler/ht/fingerprint 1.544s
--- FAIL: TestRTHistogram (0.00s)
graphics_test.go:26: Unexpected error fork/exec /usr/bin/Rscript: no such file or directory
Hello from testdata/custom.js
--- FAIL: TestScreenshotPass (0.01s)
phantomjs_test.go:348: 0. Basic Screenshot of Home, Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:348: 1. Greet Anonymous (white bg), Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:348: 3. Greet Red user (red bg), Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:348: 6. Greet RT user (olive bg), Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:348: 8. Greet RT user (lime bg), Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:348: 10. Greet Anonymous (different sizes), Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:348: 11. Greet Bob, ignoring name, Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:348: 12. Greet Bob, tollerating difference, Fail: exec: "phantomjs": executable file not found in $PATH
--- FAIL: TestRenderedHTMLPassing (0.00s)
phantomjs_test.go:508: 1. Welcome Anonymous, rendered body, Fail: exec: "phantomjs": executable file not found in $PATH
phantomjs_test.go:508: 3. Welcome Joe, Fail: exec: "phantomjs": executable file not found in $PATH
--- FAIL: TestRenderingTime2 (0.00s)
phantomjs_test.go:603: Want status=Pass and nil error, got Fail, exec: "phantomjs": executable file not found in $PATH <*exec.Error>
--- FAIL: TestFancyScreenshotPass (0.00s)
phantomjs_test.go:697: Want status=Pass and nil error, got Fail, exec: "phantomjs": executable file not found in $PATH <*exec.Error>
FAIL
Line 557 in f4a52f6
Are you open for the feature to extend the written file MainTest-XX.ResponseBody
with the correct file extension depending on the content type?
E.g. MainTest-04.ResponseBody.json
for pure JSON responses; MainTest-04.ResponseBody.html
for HTML docs ... would be easier to open the files with the correct tools in an operating system.
I would like to see a report which states the timing information of a network request.
Hopefully this feature fits into your sprint planning process ;-)
https://twitter.com/davecheney/status/779269890918146048
Printscreen from the Chrome Network Panel
https://github.com/dop251/goja
;-)
As an idea: ht might read the top n most requested URLs provided by an analytics platform like Google Analytics (GA).
If you can show me the entry point where the benchmarks/performance tests will be started I might implement that feature myself, if you are interested in it.
Assuming PRODUCTURL is not defined (i.e. not listed in "Variables" section during test execution), incorrect request is made:
GET https://xxxx:9002/.%7B%7BPRODUCTURL%7D%7D
Expected: Error message should be displayed.
See printscreen
Idea to convert http.Request into curl: https://github.com/moul/http2curl/blob/master/http2curl.go
I have a suite:
{
Name: " Shop Basic Functionality",
KeepCookies: true,
Main: [
{File: "homepage-basics.ht"}
]
Teardown: [
{File: "get-admin-token.ht"}
],
}
The file homepage-basics.ht
exists but the file get-admin-token.ht
does not exists.
When I run now:
$ ./ht/ht_darwin exec -output ./reports/ -Dfile ./env/local.json ./frontend/index.suite
The result is:
$ ./ht/ht_darwin exec -output ./reports/ -Dfile ./env/local.json ./frontend/index.suite
Seeding random number generator with 1507875229665009841.
Resetting global counter to 1.
Using "phantomjs" as PhantomJS executable.
Total 0, Passed 0, Skipped 0, Errored 0, Failed 0, Bogus 0
NOTRUN
There is no indication that a file is missing or spelt wrong. You can search all over the suite and test files to look for the bug ... bit time consuming.
Would be nice to have an appropriate error message. ๐
ht version: latest
user at machine in ~/GoPro/src/github.com/vdobler/ht/cmd/ht on master
$ go build .
# github.com/vdobler/ht/cmd/ht
./load.go:87: scenarios[i].Log undefined (type suite.Scenario has no field or method Log)
I'm using the master branch for integration testing in a travis CI build but now my build is breaking.
Would you please fix it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.