speedos 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +5 -0
  3. data/Gemfile.lock +94 -0
  4. data/LICENSE.txt +9 -0
  5. data/README.md +104 -0
  6. data/bin/browsermob-proxy-2.0-beta-8/LICENSE.txt +203 -0
  7. data/bin/browsermob-proxy-2.0-beta-8/README.md +197 -0
  8. data/bin/browsermob-proxy-2.0-beta-8/README.txt +3 -0
  9. data/bin/browsermob-proxy-2.0-beta-8/bin/browsermob-proxy +100 -0
  10. data/bin/browsermob-proxy-2.0-beta-8/bin/browsermob-proxy.bat +105 -0
  11. data/bin/browsermob-proxy-2.0-beta-8/browsermob-proxy-2.0-beta-8-javadoc.jar +0 -0
  12. data/bin/browsermob-proxy-2.0-beta-8/browsermob-proxy-2.0-beta-8-sources.jar +0 -0
  13. data/bin/browsermob-proxy-2.0-beta-8/lib/annotations-7.0.3.jar +0 -0
  14. data/bin/browsermob-proxy-2.0-beta-8/lib/ant-1.8.2.jar +0 -0
  15. data/bin/browsermob-proxy-2.0-beta-8/lib/ant-launcher-1.8.2.jar +0 -0
  16. data/bin/browsermob-proxy-2.0-beta-8/lib/aopalliance-1.0.jar +0 -0
  17. data/bin/browsermob-proxy-2.0-beta-8/lib/bcprov-jdk15on-1.47.jar +0 -0
  18. data/bin/browsermob-proxy-2.0-beta-8/lib/browsermob-proxy-2.0-beta-8.jar +0 -0
  19. data/bin/browsermob-proxy-2.0-beta-8/lib/browsermob-proxy-2.0-beta-8.pom +272 -0
  20. data/bin/browsermob-proxy-2.0-beta-8/lib/commons-codec-1.6.jar +0 -0
  21. data/bin/browsermob-proxy-2.0-beta-8/lib/commons-httpclient-3.1.jar +0 -0
  22. data/bin/browsermob-proxy-2.0-beta-8/lib/commons-io-1.3.2.jar +0 -0
  23. data/bin/browsermob-proxy-2.0-beta-8/lib/commons-lang-2.5.jar +0 -0
  24. data/bin/browsermob-proxy-2.0-beta-8/lib/commons-logging-1.1.1.jar +0 -0
  25. data/bin/browsermob-proxy-2.0-beta-8/lib/dom4j-1.6.1.jar +0 -0
  26. data/bin/browsermob-proxy-2.0-beta-8/lib/freemarker-2.3.10.jar +0 -0
  27. data/bin/browsermob-proxy-2.0-beta-8/lib/guava-r07.jar +0 -0
  28. data/bin/browsermob-proxy-2.0-beta-8/lib/guice-3.0.jar +0 -0
  29. data/bin/browsermob-proxy-2.0-beta-8/lib/guice-multibindings-3.0.jar +0 -0
  30. data/bin/browsermob-proxy-2.0-beta-8/lib/guice-servlet-3.0.jar +0 -0
  31. data/bin/browsermob-proxy-2.0-beta-8/lib/httpclient-4.2.3.jar +0 -0
  32. data/bin/browsermob-proxy-2.0-beta-8/lib/httpcore-4.2.2.jar +0 -0
  33. data/bin/browsermob-proxy-2.0-beta-8/lib/httpmime-4.2.3.jar +0 -0
  34. data/bin/browsermob-proxy-2.0-beta-8/lib/icu4j-2.6.1.jar +0 -0
  35. data/bin/browsermob-proxy-2.0-beta-8/lib/jackson-core-asl-1.7.1.jar +0 -0
  36. data/bin/browsermob-proxy-2.0-beta-8/lib/jackson-mapper-asl-1.7.1.jar +0 -0
  37. data/bin/browsermob-proxy-2.0-beta-8/lib/javax.inject-1.jar +0 -0
  38. data/bin/browsermob-proxy-2.0-beta-8/lib/jaxen-1.1.1.jar +0 -0
  39. data/bin/browsermob-proxy-2.0-beta-8/lib/jcip-annotations-1.0.jar +0 -0
  40. data/bin/browsermob-proxy-2.0-beta-8/lib/jdom-1.0.jar +0 -0
  41. data/bin/browsermob-proxy-2.0-beta-8/lib/jetty-continuation-7.3.0.v20110203.jar +0 -0
  42. data/bin/browsermob-proxy-2.0-beta-8/lib/jetty-http-7.3.0.v20110203.jar +0 -0
  43. data/bin/browsermob-proxy-2.0-beta-8/lib/jetty-io-7.3.0.v20110203.jar +0 -0
  44. data/bin/browsermob-proxy-2.0-beta-8/lib/jetty-security-7.3.0.v20110203.jar +0 -0
  45. data/bin/browsermob-proxy-2.0-beta-8/lib/jetty-server-7.3.0.v20110203.jar +0 -0
  46. data/bin/browsermob-proxy-2.0-beta-8/lib/jetty-servlet-7.3.0.v20110203.jar +0 -0
  47. data/bin/browsermob-proxy-2.0-beta-8/lib/jetty-util-7.3.0.v20110203.jar +0 -0
  48. data/bin/browsermob-proxy-2.0-beta-8/lib/jopt-simple-3.2.jar +0 -0
  49. data/bin/browsermob-proxy-2.0-beta-8/lib/json-20080701.jar +0 -0
  50. data/bin/browsermob-proxy-2.0-beta-8/lib/jsoup-1.4.1.jar +0 -0
  51. data/bin/browsermob-proxy-2.0-beta-8/lib/maven-metadata-appassembler.xml +43 -0
  52. data/bin/browsermob-proxy-2.0-beta-8/lib/mvel2-2.0.18.jar +0 -0
  53. data/bin/browsermob-proxy-2.0-beta-8/lib/saxpath-1.0-FCS.jar +0 -0
  54. data/bin/browsermob-proxy-2.0-beta-8/lib/selenium-api-2.29.1.jar +0 -0
  55. data/bin/browsermob-proxy-2.0-beta-8/lib/servlet-api-2.5.jar +0 -0
  56. data/bin/browsermob-proxy-2.0-beta-8/lib/sitebricks-0.8.3.jar +0 -0
  57. data/bin/browsermob-proxy-2.0-beta-8/lib/slf4j-api-1.5.3.jar +0 -0
  58. data/bin/browsermob-proxy-2.0-beta-8/lib/slf4j-jdk14-1.5.3.jar +0 -0
  59. data/bin/browsermob-proxy-2.0-beta-8/lib/xalan-2.6.0.jar +0 -0
  60. data/bin/browsermob-proxy-2.0-beta-8/lib/xmlParserAPIs-2.6.2.jar +0 -0
  61. data/bin/browsermob-proxy-2.0-beta-8/lib/xom-1.0.jar +0 -0
  62. data/bin/browsermob-proxy-2.0-beta-8/lib/xpp3_min-1.1.4c.jar +0 -0
  63. data/bin/browsermob-proxy-2.0-beta-8/lib/xstream-1.3.1.jar +0 -0
  64. data/bin/browsermob-proxy-2.0-beta-8/ssl-support/blank_crl.dec +0 -0
  65. data/bin/browsermob-proxy-2.0-beta-8/ssl-support/blank_crl.pem +12 -0
  66. data/bin/browsermob-proxy-2.0-beta-8/ssl-support/cybervillainsCA.cer +0 -0
  67. data/bin/browsermob-proxy-2.0-beta-8/ssl-support/cybervillainsCA.jks +0 -0
  68. data/bin/speedos +41 -0
  69. data/lib/speedos/configuration.rb +11 -0
  70. data/lib/speedos/log.rb +16 -0
  71. data/lib/speedos/models/entries.rb +29 -0
  72. data/lib/speedos/models/record.rb +32 -0
  73. data/lib/speedos/page.rb +52 -0
  74. data/lib/speedos/performance.rb +22 -0
  75. data/lib/speedos.rb +14 -0
  76. data/spec/lib/entries_spec.rb +33 -0
  77. data/spec/models/record_spec.rb +24 -0
  78. data/spec/spec_helper.rb +34 -0
  79. data/spec/support/mongoid.yml +6 -0
  80. data/speedos.gemspec +25 -0
  81. data/template/.irbrc +1 -0
  82. data/template/Rakefile +22 -0
  83. data/template/initializer.rb +12 -0
  84. data/template/mongoid.yml +12 -0
  85. metadata +258 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6091d26639cdfd952252c65bcc869c3d8d0dcdf5
4
+ data.tar.gz: 844e13df23e11dc9b9ed5c1d7aff2eb6cc5a61d7
5
+ SHA512:
6
+ metadata.gz: 42b8294b4404ea840e51d4746b3eed66c77d42aa4d4cf9249923d39fcc6b570f20d8323c6060774b85d1b1b643ec8f5959a0feb79efb447b00c43f0222b86315
7
+ data.tar.gz: 528b4604ca39d911f935ed7e7a89dbf39eb9ac71b33c286def8ca96c0a0b88a93de004272e33e87b0b1cb2ab88d505f9b33fc37fca3bfcace38aae1ac2ee4aa2
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+ # NOTE: Don't do this! See update below.
4
+ gem 'rspec'
5
+ gem 'database_cleaner'
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ speedos (0.0.1)
5
+ browsermob-proxy (= 0.1.1)
6
+ capybara (= 2.1.0)
7
+ faker (= 1.1.2)
8
+ logger (= 1.2.8)
9
+ mongoid (= 3.1.4)
10
+ selenium-webdriver (= 2.33)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ activemodel (3.2.12)
16
+ activesupport (= 3.2.12)
17
+ builder (~> 3.0.0)
18
+ activesupport (3.2.12)
19
+ i18n (~> 0.6)
20
+ multi_json (~> 1.0)
21
+ addressable (2.3.5)
22
+ browsermob-proxy (0.1.1)
23
+ childprocess
24
+ har
25
+ multi_json (~> 1.0)
26
+ rest-client
27
+ builder (3.0.4)
28
+ capybara (2.1.0)
29
+ mime-types (>= 1.16)
30
+ nokogiri (>= 1.3.3)
31
+ rack (>= 1.0.0)
32
+ rack-test (>= 0.5.4)
33
+ xpath (~> 2.0)
34
+ childprocess (0.3.9)
35
+ ffi (~> 1.0, >= 1.0.11)
36
+ database_cleaner (1.0.1)
37
+ diff-lcs (1.2.4)
38
+ faker (1.1.2)
39
+ i18n (~> 0.5)
40
+ ffi (1.9.0)
41
+ har (0.0.9)
42
+ jschematic (>= 0.1.0)
43
+ json
44
+ launchy (>= 0.3.7)
45
+ i18n (0.6.4)
46
+ jschematic (0.1.0)
47
+ addressable
48
+ json (1.8.0)
49
+ launchy (2.3.0)
50
+ addressable (~> 2.3)
51
+ logger (1.2.8)
52
+ mime-types (1.23)
53
+ mini_portile (0.5.1)
54
+ mongoid (3.1.4)
55
+ activemodel (~> 3.2)
56
+ moped (~> 1.4)
57
+ origin (~> 1.0)
58
+ tzinfo (~> 0.3.22)
59
+ moped (1.5.0)
60
+ multi_json (1.7.7)
61
+ nokogiri (1.6.0)
62
+ mini_portile (~> 0.5.0)
63
+ origin (1.1.0)
64
+ rack (1.5.2)
65
+ rack-test (0.6.2)
66
+ rack (>= 1.0)
67
+ rest-client (1.6.7)
68
+ mime-types (>= 1.16)
69
+ rspec (2.14.1)
70
+ rspec-core (~> 2.14.0)
71
+ rspec-expectations (~> 2.14.0)
72
+ rspec-mocks (~> 2.14.0)
73
+ rspec-core (2.14.3)
74
+ rspec-expectations (2.14.0)
75
+ diff-lcs (>= 1.1.3, < 2.0)
76
+ rspec-mocks (2.14.1)
77
+ rubyzip (0.9.9)
78
+ selenium-webdriver (2.33.0)
79
+ childprocess (>= 0.2.5)
80
+ multi_json (~> 1.0)
81
+ rubyzip
82
+ websocket (~> 1.0.4)
83
+ tzinfo (0.3.37)
84
+ websocket (1.0.7)
85
+ xpath (2.0.0)
86
+ nokogiri (~> 1.3)
87
+
88
+ PLATFORMS
89
+ ruby
90
+
91
+ DEPENDENCIES
92
+ database_cleaner
93
+ rspec
94
+ speedos!
data/LICENSE.txt ADDED
@@ -0,0 +1,9 @@
1
+ Copyright (c) 2012-2013 SimplyBusiness
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
9
+ NOTE: Third-party libraries and softwares inside /bin/ are subject to their own licences (refer to LICENCE.txt within the third-party folder)
data/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # Speedos
2
+
3
+ ## What is Speedos?
4
+ Speedos incorporates [BrowserMob Proxy](http://bmp.lightbody.net) along with [Capybara](https://github.com/jnicklas/capybara), recording the web traffic and time taken to load all elements on each of the pages within a user journey. The aim is to identify any performance related issues, such as specific items that take a long time to load on page.
5
+
6
+ ## Installation
7
+ Put speedos on your Gemfile
8
+
9
+ gem 'speedos'
10
+
11
+ Or, install it via rubygem
12
+
13
+ $ gem install speedos
14
+
15
+ The easiest and quickest way to get you started is to run the init script
16
+
17
+ $ speedos init
18
+
19
+ and it will generate following file structure for you:
20
+
21
+ ├── .irbrc
22
+ ├── Rakefile
23
+ ├── config
24
+ │   ├── initializer.rb
25
+ │   └── mongoid.yml
26
+ ├── helpers
27
+ ├── log
28
+ └── scripts
29
+
30
+ ## Configuration
31
+
32
+ ### Mongoid
33
+ It is essential to let speedos know the location of your mongoid.yml by...
34
+
35
+ Speedos::Configuration.load_mongoid_config('/location/to/my/mongoid.yml')
36
+
37
+ Refer to mongoid documentation for the correct format of mongoid.yml <http://mongoid.org/en/mongoid/docs/installation.html>
38
+
39
+ ### Logger
40
+ By default, speedos will output all the logging using STDOUT, you can override this method by either
41
+
42
+ # pass in a Logger Object
43
+ Speedos::Log.logger = Logger.new(…)
44
+
45
+ or
46
+
47
+ # the location where you want the log to be saved
48
+ Speedos::Log.logger = "/location/to/desire/log/location"
49
+
50
+ ## Create your own script
51
+ you should put all your script under `/scripts`
52
+
53
+ require 'speedos'
54
+
55
+ Speedos::Performance.test do |page|
56
+ page.is 'simplybusiness-main-page' do
57
+ # page.driver is a capybara session instance
58
+ page.driver.visit 'https://www.simplybusiness.co.uk/'
59
+ page.driver.fill_in 'ctaText', with: "IT contractor"
60
+ end
61
+
62
+ page.is 'business-insurance-page' do
63
+ page.driver.find_button('ctaBtn').click
64
+ end
65
+ end
66
+
67
+ ## To execute the scripts
68
+ If you use `init` to generate your structure, you should get `Rakefile` created. And it will create rake task for all the scripts you have created in `/scripts`
69
+
70
+ └── scripts
71
+ ├── earth
72
+ │   └── grass.rb
73
+ ├── human.rb
74
+ └── sky
75
+ ├── cloud.rb
76
+ └── rain.rb
77
+
78
+ For example, if you have above scripts structure, then you should get the following rake tasks created
79
+
80
+ $ rake -T
81
+
82
+ rake earth:grass # run the script located in /Users/pwu/test/scripts/earth/grass.rb
83
+ rake human # run the script located in /Users/pwu/test/scripts/human.rb
84
+ rake sky:cloud # run the script located in /Users/pwu/test/scripts/sky/cloud.rb
85
+ rake sky:rain # run the script located in /Users/pwu/test/scripts/sky/rain.rb
86
+
87
+
88
+ ## Report
89
+ You can access the performance data via `Speedos::Record` object
90
+
91
+ $ irb
92
+
93
+ > Speedos::Record.first.pages
94
+ #=> [Entries: ["simplybusiness-main-page"], Entries: ["google-result-page"]]
95
+
96
+ > Speedos::Record.first.pages.first
97
+ #=> Entries: ["simplybusiness-main-page"]
98
+
99
+ > Speedos::Record.first.pages.first.total_load_time
100
+ #=> 3828.0
101
+ # which is the total loading time for the page in milliseconds
102
+
103
+
104
+
@@ -0,0 +1,203 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
@@ -0,0 +1,197 @@
1
+ BrowserMob Proxy
2
+ ================
3
+
4
+ BrowserMob Proxy is a simple utility that makes it easy to capture performance data from browsers, typically written using automation toolkits such as Selenium and Watir.
5
+
6
+ Features
7
+ --------
8
+
9
+ The proxy is programmatically controlled via a REST interface or by being embedded directly inside Java-based programs and unit tests. It captures performance data the [HAR format](http://groups.google.com/group/http-archive-specification). It addition it also can actually control HTTP traffic, such as:
10
+
11
+ - blacklisting and whitelisting certain URL patterns
12
+ - simulating various bandwidth and latency
13
+ - remapping DNS lookups
14
+ - flushing DNS caching
15
+ - controlling DNS and request timeouts
16
+ - automatic BASIC authorization
17
+
18
+ REST API
19
+ --------
20
+
21
+ To get started, first start the proxy by running `browsermob-proxy` or `browsermob-proxy.bat` in the bin directory:
22
+
23
+ $ sh browsermob-proxy -port 9090
24
+ INFO 05/31 03:12:48 o.b.p.Main - Starting up...
25
+ 2011-05-30 20:12:49.517:INFO::jetty-7.3.0.v20110203
26
+ 2011-05-30 20:12:49.689:INFO::started o.e.j.s.ServletContextHandler{/,null}
27
+ 2011-05-30 20:12:49.820:INFO::Started SelectChannelConnector@0.0.0.0:9090
28
+
29
+ Once started, there won't be an actual proxy running until you create a new proxy. You can do this by POSTing to /proxy:
30
+
31
+ [~]$ curl -X POST http://localhost:9090/proxy
32
+ {"port":9091}
33
+
34
+ or optionally specify your own port:
35
+
36
+ [~]$ curl -X POST -d 'port=9099' http://localhost:9090/proxy
37
+ {"port":9099}
38
+
39
+ Once that is done, a new proxy will be available on the port returned. All you have to do is point a browser to that proxy on that port and you should be able to browser the internet. The following additional APIs will then be available:
40
+
41
+ - PUT /proxy/[port]/har - creates a new HAR attached to the proxy and returns the HAR content if there was a previous HAR. Supports the following parameters:
42
+ - initialPageRef - the string name of the first page ref that should be used in the HAR. Defaults to "Page 1".
43
+ - captureHeaders - Boolean, capture headers
44
+ - captureContent - Boolean, capture content bodies
45
+ - captureBinaryContent - Boolean, capture binary content
46
+ - PUT /proxy/[port]/har/pageRef - starts a new page on the existing HAR. Supports the following parameters:
47
+ - pageRef - the string name of the first page ref that should be used in the HAR. Defaults to "Page N" where N is the next page number.
48
+ - PUT /proxy/[port]/har/pageRef - creates a new HAR attached to the proxy and returns the HAR content if there was a previous HAR
49
+ - DELETE /proxy/[port] - shuts down the proxy and closes the port
50
+ - GET /proxy/[port]/har - returns the JSON/HAR content representing all the HTTP traffic passed through the proxy
51
+ - PUT /proxy/[port]/whitelist - Sets a list of URL patterns to whitelist. Takes the following parameters:
52
+ - regex - a comma separated list of regular expressions
53
+ - status - the HTTP status code to return for URLs that do not match the whitelist
54
+ - PUT /proxy/[port]/blacklist - Set a URL to blacklist. Takes the following parameters:
55
+ - regex - the blacklist regular expression
56
+ - status - the HTTP status code to return for URLs that are blacklisted
57
+ - PUT /proxy/[port]/limit - Limit the bandwidth through the proxy. Takes the following parameters:
58
+ - downstreamKbps - Sets the downstream kbps
59
+ - upstreamKbps - Sets the upstream kbps
60
+ - latency - Add the given latency to each HTTP request
61
+ - enable - (true/false) a boolean that enable bandwidth limiter. By default the limit is disabled, although setting any of the properties above will implicitly enable throttling
62
+ - payloadPercentage - a number ]0, 100] specifying what percentage of data sent is payload. e.g. use this to take into account overhead due to tcp/ip.
63
+ - maxBitsPerSecond - The max bits per seconds you want this instance of StreamManager to respect.
64
+ - POST /proxy/[port]/headers - Set and override HTTP Request headers. For example setting a custom User-Agent.
65
+ - Payload data should be json encoded set of headers (not url-encoded)
66
+ - POST /proxy/[port]/hosts - Overrides normal DNS lookups and remaps the given hosts with the associated IP address
67
+ - Payload data should be json encoded set of name/value pairs (ex: {"example.com": "1.2.3.4"})
68
+ - POST /proxy/[port]/auth/basic/[domain] - Sets automatic basic authentication for the specified domain
69
+ - Payload data should be json encoded username and password name/value pairs (ex: {"username": "myUsername", "password": "myPassword"}
70
+ - PUT /proxy/[port]/wait - wait till all request are being made
71
+ - quietPeriodInMs - Sets quiet period in milliseconds
72
+ - timeoutInMs - Sets timeout in milliseconds
73
+ - PUT /proxy/[port]/timeout - Handles different proxy timeouts. Takes the following parameters:
74
+ - requestTimeout - request timeout in milliseconds
75
+ - readTimeout - read timeout in milliseconds. Which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets). A timeout value of zero is interpreted as an infinite timeout.
76
+ - connectionTimeout - Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted as an infinite timeout.
77
+ - dnsCacheTimeout - Sets the maximum length of time that records will be stored in this Cache. A negative value disables this feature (that is, sets no limit).
78
+ - PUT /proxy/[port]/rewrite - Redirecting URL's
79
+ - matchRegex - a matching URL regular expression
80
+ - replace - replacement URL
81
+ - PUT /proxy/[port]/retry - Setting the retry count
82
+ - retrycount - the number of times a method will be retried
83
+ - DELETE /proxy/[port]/dns/cache - Empties the Cache.
84
+
85
+ For example, once you've started the proxy you can create a new HAR to start recording data like so:
86
+
87
+ [~]$ curl -X PUT -d 'initialPageRef=Foo' http://localhost:8080/proxy/9091/har
88
+
89
+ Now when traffic goes through port 9091 it will be attached to a page reference named "Foo". Consult the HAR specification for more info on what a "pageRef" is. You can also start a new pageRef like so:
90
+
91
+ [~]$ curl -X PUT -d 'pageRef=Bar' http://localhost:8080/proxy/9091/har/pageRef
92
+
93
+ That will ensure no more HTTP requests get attached to the old pageRef (Foo) and start getting attached to the new pageRef (Bar). You can also get the HAR content at any time like so:
94
+
95
+ [~]$ curl http://localhost:8080/proxy/9091/har
96
+
97
+ Sometimes you will want to route requests through an upstream proxy server. In this case specify your proxy server by adding the httpProxy parameter to your create proxy request:
98
+
99
+ [~]$ curl -X POST http://localhost:9090/proxy?httpProxy=yourproxyserver.com:8080
100
+ {"port":9091}
101
+
102
+ Alternatively, you can specify the upstream proxy config for all proxies created using the standard JVM [system properties for HTTP proxies](http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html).
103
+ Note that you can still override the default upstream proxy via the POST payload, but if you omit the payload the JVM
104
+ system properties will be used to specify the upstream proxy.
105
+
106
+ *TODO*: Other REST APIs supporting all the BrowserMob Proxy features will be added soon.
107
+
108
+ Embedded Mode
109
+ -------------
110
+
111
+ If you're using Java and Selenium, the easiest way to get started is to embed the project directly in your test. First, you'll need to make sure that all the dependencies are imported in to the project. You can find them in the *lib* directory. Or, if you're using Maven, you can add this to your pom:
112
+
113
+ <dependency>
114
+ <groupId>net.lightbody.bmp</groupId>
115
+ <artifactId>browsermob-proxy</artifactId>
116
+ <version>LATEST_VERSION (ex: 2.0-beta-8)</version>
117
+ <scope>test</scope>
118
+ </dependency>
119
+
120
+ Once done, you can start a proxy using `net.lightbody.bmp.proxy.ProxyServer`:
121
+
122
+ ProxyServer server = new ProxyServer(9090);
123
+ server.start();
124
+
125
+ This class supports every feature that the proxy supports. In fact, the REST API is a subset of the methods exposed here, so new features will show up here before they show up in the REST API. Consult the Javadocs for the full API.
126
+
127
+ If your project already defines a Selenium dependency then you may want to exclude the version that browsermob-proxy pulls in, like so:
128
+
129
+ <dependency>
130
+ <groupId>net.lightbody.bmp</groupId>
131
+ <artifactId>browsermob-proxy</artifactId>
132
+ <version>LATEST_VERSION (ex: 2.0-beta-8)</version>
133
+ <scope>test</scope>
134
+ <exclusions>
135
+ <exclusion>
136
+ <groupId>org.seleniumhq.selenium</groupId>
137
+ <artifactId>selenium-api</artifactId>
138
+ </exclusion>
139
+ </exclusions>
140
+ </dependency>
141
+
142
+
143
+ Using With Selenium
144
+ -------------------
145
+
146
+ You can use the REST API with Selenium however you want. But if you're writing your tests in Java and using Selenium 2, this is the easiest way to use it:
147
+
148
+ // start the proxy
149
+ ProxyServer server = new ProxyServer(4444);
150
+ server.start();
151
+
152
+ // get the Selenium proxy object
153
+ Proxy proxy = server.seleniumProxy();
154
+
155
+ // configure it as a desired capability
156
+ DesiredCapabilities capabilities = new DesiredCapabilities();
157
+ capabilities.setCapability(CapabilityType.PROXY, proxy);
158
+
159
+ // start the browser up
160
+ WebDriver driver = new FirefoxDriver(capabilities);
161
+
162
+ // create a new HAR with the label "yahoo.com"
163
+ server.newHar("yahoo.com");
164
+
165
+ // open yahoo.com
166
+ driver.get("http://yahoo.com");
167
+
168
+ // get the HAR data
169
+ Har har = server.getHar();
170
+
171
+
172
+ HTTP Request Manipulation
173
+ -------------------
174
+
175
+ While not yet available via the REST interface, you can manipulate the requests like so:
176
+
177
+ server.addRequestInterceptor(new RequestInterceptor() {
178
+ @Override
179
+ public void process(BrowserMobHttpRequest request) {
180
+ request.getMethod().removeHeaders("User-Agent");
181
+ request.getMethod().addHeader("User-Agent", "Bananabot/1.0");
182
+ }
183
+ });
184
+
185
+ We will soon be adding support for this advanced capability in the REST interface as well, using JavaScript snippets that can be posted as the interceptor code.
186
+
187
+ SSL Support
188
+ -----------
189
+
190
+ While the proxy supports SSL, it requires that a Certificate Authority be installed in to the browser. This allows the browser to trust all the SSL traffic coming from the proxy, which will be proxied using a classic man-in-the-middle technique. IT IS CRITICAL THAT YOU NOT INSTALL THIS CERTIFICATE AUTHORITY ON A BROWSER THAT IS USED FOR ANYTHING OTHER THAN TESTING.
191
+
192
+ If you're doing testing with Selenium, you'll want to make sure that the browser profile that gets set up by Selenium not only has the proxy configured, but also has the CA installed. Unfortuantely, there is no API for doing this in Selenium, so you'll have to solve it uniquely for each browser type. We hope to make this easier in upcoming releases.
193
+
194
+ NodeJS Support
195
+ --------------
196
+
197
+ NodeJS bindings for browswermob-proxy are available [here](https://github.com/zzo/browsermob-node). Built-in support for [Selenium][http://seleniumhq.com] or use [CapserJS-on-PhantomJS](http://casperjs.org) or anything else to drive traffic for HAR generation.
@@ -0,0 +1,3 @@
1
+ Please see README.md (in Markdown format) or view it at:
2
+
3
+ https://github.com/lightbody/browsermob-proxy