Giter VIP home page Giter VIP logo

hargo's Introduction

Hargo

Hargo Build Statusย GoDoc Go Report Card Join the chat at https://gitter.im/mrichman/hargo GitHub license GitHub issues Twitter

Hargo parses HAR files, can convert to curl format, and serve as a load test driver.

NAME:
   hargo - work with HTTP Archive (.har) files

USAGE:
   hargo <command> [arguments] <.har file>

VERSION:
   0.1.2-dev.57 (da53069)

AUTHOR:
   Mark A. Richman <[email protected]>

COMMANDS:
     fetch, f     Fetch URLs in .har
     curl, c      Convert .har to curl
     run, r       Run .har file
     validate, v  Validate .har file
     dump, d      Dump .har file
     load, l      Load test .har file
     help, h      Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug        Show debug output
   --help, -h     show help
   --version, -v  print the version

COPYRIGHT:
   (c) 2022 Mark A. Richman

Building and Running Hargo

git clone https://github.com/mrichman/hargo.git
cd hargo
make install
hargo validate test/golang.org.har

About HAR Files

If you use Google Chrome, you can record these files by following the steps below:

  1. Right-click anywhere on that page and click on Inspect Element to open Chrome's Developer Tools
  2. The Developer Tools will open as a panel at the bottom of the page. Click on the Network tab.
  3. Click the Record button, which is the solid black circle at the bottom of the Network tab, and you'll start recording activity in your browser.
  4. Refresh the page and start working normally
  5. Right-click within the Network tab and click Save as HAR with Content to save a copy of the activity that you recorded.
  6. Within the file window, save the HAR file.

Commands

Fetch

The fetch command downloads all resources references in .har file:

hargo fetch foo.har

This will produce a directory named hargo-fetch-yyyymmddhhmmss containing all assets references by the .har file. This is similar to what you'd see when invoking wget on a particular URL.

Curl

The curl command will output a curl command line for each entry in the .har file.

hargo curl foo.har

Run

The run command executes each HTTP request in .har file:

hargo run foo.har

This is similar to fetch but will not save any output.

Validate

The validate command will report any errors in the format of a .har file.

hargo validate foo.har

HAR file format is defined here: https://w3c.github.io/web-performance/specs/HAR/Overview.html

Dump

Dump prints information about all HTTP requests in .har file

hargo dump foo.har

Load

Hargo can act as a load test agent. Given a .har file, hargo can spawn a number of concurrent workers to repeat each HTTP request in order. By default, hargo will spawn 10 workers and run for a duration of 60 seconds.

Hargo will also save its results to InfluxDB, if available. Each HTTP response is stored as a point of time-series data, which can be graphed by Chronograf, Grafana, or similar visualization tool for analysis.

Docker

Build container

docker build -t hargo .

Run container

docker run --rm -v `pwd`/test:/test hargo hargo run /test/golang.org.har

Docker-compose

The example docker-compose file will start three containers:

  • hargo
  • influxdb
  • grafana

The hargo container will first needs to be built. See build. When the compose file is run it will start a hargo load process that will write the results to InfluxDB. This InfluxDB instance can be viewed using the grafana container. This contains an example dashboard showing the latency of the executed request. Username/password for all the containers is hargo/hargo.

commands

cd example/docker-compose
docker-compose up
docker-compose down -v

hargo's People

Contributors

arbakker avatar braderz avatar hajimehoshi avatar hyl avatar irori avatar johnweldon avatar marcelmiguel avatar mrichman avatar thoorium avatar woutervisscher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hargo's Issues

tag `0.1.2` is inconsistent with prior tags, should be `v0.1.2`

Hey there -- was trying this package out and went down a rabbit hole trying to figure out why I couldn't get the latest version. After some detective work I noticed that your latest version is tagged 0.1.2 (no v) whereas the previous version was v0.1.1.

I suspect this is causing people to not get 0.1.1 when they pull.

JSON tags messed up

Hi there! Just wanted to provide some feedback on some ways you could improve the json struct tags in hargo:

  1. Right now you have a lot of fields like this:
Text string `json:"omitempty"`

What you're doing here is telling the json unmarshaler to look for the field omitempty in the json object, which isn't what you want. What I think you're trying to do is this:

Text string `json:",omitempty"`

Which tells it to look for text or Text in the json object, and omit the field when marshaling if it's empty.

  1. It would break backwards compat, but setting the field names to be their lower case versions, like so:
Text string `json:"text,omitempty"`

would make it so that once you have a Har unmarshaled into your program you can unmarshal it again into the same form, rather than a new set of objects with different field names that can't be used by chrome or any other tool which is reading in Har as json objects.

I'm going to make a fork of your project and implement these changes, if you like I can PR them back up. Thanks for all the work on it so far, it's been really helpful!

this project is awesome

this project is awesome
It helped me to solve har parsing related issues
It would be better if the files downloaded by the hargo fetch command can be placed according to the directory

InfluxDB version

The version of the connector is old, please update it to work with influxdb 1.5 (the most common version).

Support think times

Think times are used to simulate human behavior that causes people to wait between interactions with a Web site. Think times occur between requests in a Web performance test and between test iterations in a load test scenario. Using think times in a load test can be useful in creating more accurate load simulations.

Without think times, URLs are requested as quickly as possible.

Having trouble with the go get command

When I run go get github.com/mrichman/hargo I receive this error "can't load package: package github.com/mrichman/hargo: no Go files in /Users/billy/go/src/github.com/mrichman/hargo"

Can someone explain what I'm doing wrong?

Thanks!

Dependency changed

I found the following error:

cmd\hargo\hargo.go:13:2: cannot find package "github.com/urfave/cli" in any of:
        C:\Go\src\github.com\urfave\cli (from $GOROOT)
        C:\Users\Csuto\go\src\github.com\urfave\cli (from $GOPATH)

I found out that happened as the cli has changed its repository (or whatever it called in GO, I haven't ever used it before).

The new repository is: gopkg.in/urfave/cli.v1. It should be changed in hargo.go import part, and in the dependecies.

Workaround:
Change it in hargo.go and run go get gopkg.in/urfave/cli.v1.

changes to make curl script more usable

Thank you very much for the project!

I made a few changes for my use case.

  1. Don't send cookies in both the -b parameter AND in the -H headers.
  2. Don't (explicitly) send HTTP/2 pseudo-headers (it breaks CURL parsing, not sure if there's another way, but assume CURL will generate these correctly for HTTP/2 if needed).
  3. UNIX-specific, but escape double-quotes in HEADER values.
diff --git a/curl.go b/curl.go
index 4e3fe88..69300c1 100644
--- a/curl.go
+++ b/curl.go
@@ -54,7 +54,13 @@ func fromEntry(entry Entry) (string, error) {
        }
 
        for _, h := range entry.Request.Headers {
-               command += " -H \"" + h.Name + ": " + h.Value + "\" "
+               if strings.EqualFold(h.Name, "cookie") {
+                       continue
+               }
+               if strings.HasPrefix(h.Name, ":") {
+                       continue
+               }
+               command += " -H \"" + h.Name + ": " + strings.ReplaceAll(h.Value, "\"", "\\\"") + "\" "
        }
 
        if entry.Request.Method == "POST" && len(entry.Request.PostData.Text) > 0 {

where is it saving , there is nothing in my gopath?

$ go get github.com/mrichman/hargo
$ cd $GOPATH/src/github.com/mrichman/hargo

-bash: cd: /Users/ishandutta2007/gopath/src/github.com/mrichman/hargo: No such file or directory

$ echo $GOPATH

/Users/ishandutta2007/gopath

$ ls /Users/ishandutta2007/gopath
$

InfluxDB: load test with large har file

When a load test is started with a large har file that cannot be processed in the given duration, no results will be written in InfluxDB. This is because the waitTimeout func will stop the load test before the results are pushed to InfluxDB.
Regarding this issue I've made a pull request #19

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.