loadrunner 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/lib/load_runner/client.rb +15 -6
- data/lib/load_runner/command_line.rb +12 -2
- data/lib/load_runner/docopt.txt +20 -7
- data/lib/load_runner/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac288df3a479098d56c66cf0a2501fd5c8d59317d1243aba52290340c60892af
|
4
|
+
data.tar.gz: 74cdcf9ef45c4d7b913352b686160203aa03c6ef2722ea5fccc05020691bd3a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fc9eec533a6d826b86b1e9c227375230c114f9763463239cd8c886cdc5d0ec57a4d53ae5be11e0363512d6c172e01b764c129ef64e740fea89549b9bc88046e
|
7
|
+
data.tar.gz: 981e1c6df07e8799691b69ea81528bb83db9edc2ff0b3e9c17be04ac5453a384c423e15b199d8abb86493de660ba47cf63db8eefbdf74444d312f505fba9bbd9
|
data/README.md
CHANGED
@@ -41,7 +41,7 @@ Getting Started
|
|
41
41
|
$ loadrunner server
|
42
42
|
|
43
43
|
# In another terminal, send a sample webhook event
|
44
|
-
$ loadrunner
|
44
|
+
$ loadrunner event localhost:3000 myrepo push master
|
45
45
|
|
46
46
|
# Verify the handler was executed
|
47
47
|
$ cat output.txt
|
@@ -61,12 +61,13 @@ You can run both the server and the client using Docker.
|
|
61
61
|
$ docker run -p3000:3000 dannyben/loadrunner server
|
62
62
|
|
63
63
|
# Client
|
64
|
-
$ docker run dannyben/loadrunner
|
64
|
+
$ docker run dannyben/loadrunner event http://webhook.server.com/payload repo push
|
65
65
|
|
66
66
|
If you wish to connect the client to the server you are running through Docker,
|
67
67
|
you can do something like this:
|
68
68
|
|
69
|
-
$ docker run --network host dannyben/loadrunner
|
69
|
+
$ docker run --network host dannyben/loadrunner event http://localhost:3000/payload repo push
|
70
70
|
|
71
|
+
See also: The [docker-compose file](docker-compose.yml).
|
71
72
|
|
72
73
|
[1]: http://www.rubydoc.info/gems/loadrunner
|
data/lib/load_runner/client.rb
CHANGED
@@ -6,13 +6,22 @@ module LoadRunner
|
|
6
6
|
# Send simulated GitHub events to any webhook server
|
7
7
|
class Client
|
8
8
|
include HTTParty
|
9
|
-
attr_accessor :secret_token, :
|
9
|
+
attr_accessor :secret_token, :host, :host_path, :payload, :encoding
|
10
10
|
|
11
11
|
def initialize(opts={})
|
12
12
|
@secret_token = opts[:secret_token]
|
13
|
-
@base_url = opts[:base_url] || 'localhost:3000/payload'
|
14
13
|
@encoding = opts[:encoding] || :json
|
15
|
-
|
14
|
+
|
15
|
+
base_url = opts[:base_url] || 'http://localhost:3000/payload'
|
16
|
+
base_url = "http://#{base_url}" unless base_url =~ /^http/
|
17
|
+
|
18
|
+
url_parts = URI.parse base_url
|
19
|
+
@host_path = url_parts.path
|
20
|
+
url_parts.path = ''
|
21
|
+
|
22
|
+
@host = url_parts.to_s
|
23
|
+
|
24
|
+
self.class.base_uri host
|
16
25
|
end
|
17
26
|
|
18
27
|
# Send a simulated event using a shorthand syntax. opts can contain
|
@@ -30,15 +39,15 @@ module LoadRunner
|
|
30
39
|
def send_payload(event, payload)
|
31
40
|
@payload = payload.is_a?(String) ? payload : payload.to_json
|
32
41
|
@payload = URI.encode_www_form(payload: @payload) if encoding == :form
|
33
|
-
self.class.post
|
42
|
+
self.class.post host_path, body: @payload, headers: headers(event)
|
34
43
|
end
|
35
44
|
|
36
45
|
private
|
37
46
|
|
38
47
|
def headers(event=:push)
|
39
48
|
{}.tap do |header|
|
40
|
-
header['
|
41
|
-
header['
|
49
|
+
header['X-GitHub-Event'] = event.to_s if event
|
50
|
+
header['X-Hub-Signature'] = signature if secret_token
|
42
51
|
header['Content-Type'] = content_type[encoding]
|
43
52
|
end
|
44
53
|
end
|
@@ -9,14 +9,24 @@ module LoadRunner
|
|
9
9
|
|
10
10
|
version VERSION
|
11
11
|
docopt File.expand_path 'docopt.txt', __dir__
|
12
|
-
subcommands [
|
12
|
+
subcommands [:event, :payload, :status, :server]
|
13
13
|
|
14
|
-
def
|
14
|
+
def event
|
15
15
|
client = Client.new client_opts
|
16
16
|
response = client.send_event args['EVENT'], payload_opts
|
17
17
|
show response
|
18
18
|
end
|
19
19
|
|
20
|
+
def payload
|
21
|
+
client = Client.new client_opts
|
22
|
+
file = args['FILE']
|
23
|
+
raise ArgumentError, "File not found: #{file}" unless File.exist? file
|
24
|
+
|
25
|
+
json = File.read file
|
26
|
+
response = client.send_payload args['EVENT'], json
|
27
|
+
show response
|
28
|
+
end
|
29
|
+
|
20
30
|
def server
|
21
31
|
Server.prepare port: args['--port'], bind: args['--bind']
|
22
32
|
Server.run!
|
data/lib/load_runner/docopt.txt
CHANGED
@@ -2,7 +2,8 @@ LoadRunner
|
|
2
2
|
|
3
3
|
Usage:
|
4
4
|
loadrunner server [--port N --bind IP]
|
5
|
-
loadrunner
|
5
|
+
loadrunner event URL REPO EVENT [REF --form]
|
6
|
+
loadrunner payload URL EVENT FILE [--form]
|
6
7
|
loadrunner status REPO SHA STATE [--context TEXT --desc TEXT --url URL]
|
7
8
|
loadrunner (-h|--help|--version)
|
8
9
|
|
@@ -10,8 +11,14 @@ Commands:
|
|
10
11
|
server
|
11
12
|
Start the webhook server.
|
12
13
|
|
13
|
-
|
14
|
-
Send a simulated GitHub event to a webhook server.
|
14
|
+
event
|
15
|
+
Send a simulated GitHub event to a webhook server. This will send a
|
16
|
+
simplified payload, with minimal properties and is intended for testing
|
17
|
+
of the loadrunner server.
|
18
|
+
|
19
|
+
payload
|
20
|
+
Send a JSON payload file to a webhook server. To obtain a proper
|
21
|
+
payload, you can copy one from your GitHub webhooks page.
|
15
22
|
|
16
23
|
status
|
17
24
|
Send status update to a github pull request.
|
@@ -29,6 +36,9 @@ Parameters:
|
|
29
36
|
EVENT
|
30
37
|
Any GitHub event, for example: push or ping.
|
31
38
|
|
39
|
+
FILE
|
40
|
+
A payload JSON file.
|
41
|
+
|
32
42
|
REF
|
33
43
|
A branch or tag specifier. This parameter supports four formats:
|
34
44
|
* branch_name
|
@@ -70,10 +80,13 @@ Environment Variables:
|
|
70
80
|
|
71
81
|
Examples:
|
72
82
|
# Simulate push events
|
73
|
-
loadrunner
|
74
|
-
loadrunner
|
75
|
-
loadrunner
|
76
|
-
loadrunner
|
83
|
+
loadrunner event localhost:3000/payload my_repo push master
|
84
|
+
loadrunner event localhost:3000/payload my_repo push branch=master
|
85
|
+
loadrunner event localhost:3000/payload my_repo push tag=staging --form
|
86
|
+
loadrunner event localhost:3000/payload my_repo push refs/tags/staging
|
87
|
+
|
88
|
+
# Send a payload file
|
89
|
+
loadrunner payload localhost:3000/payload push payload.json
|
77
90
|
|
78
91
|
# Start the server
|
79
92
|
loadrunner server
|
data/lib/load_runner/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loadrunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: super_docopt
|