simple_perf 0.0.1 → 0.0.2

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.
@@ -0,0 +1,55 @@
1
+ require 'trollop'
2
+
3
+ module SimplePerf
4
+ module CLI
5
+ class CreateGatling
6
+ include Shared
7
+
8
+ def execute
9
+ opts = Trollop::options do
10
+ version SimplePerf::VERSION
11
+ banner <<-EOS
12
+
13
+ Creates CloudFormation stack for Gatling instances.
14
+
15
+ Usage:
16
+ simple_perf create -e ENVIRONMENT -n STACK_NAME -a AMI -i INSTANCE_TYPE -s S3_BUCKET
17
+ EOS
18
+ opt :help, "Display Help"
19
+ opt :environment, "Set the target environment", :type => :string
20
+ opt :name, "Stack name to manage", :type => :string
21
+ opt :ami, "AWS ami", :type => :string
22
+ opt :instancetype, "AWS instance type", :type => :string
23
+ opt :s3bucket, "AWS s3 bucket", :type => :string
24
+ end
25
+ Trollop::die :environment, "is required but not specified" unless opts[:environment]
26
+ Trollop::die :name, "is required but not specified" unless opts[:name]
27
+ Trollop::die :ami, "is required but not specified" unless opts[:ami]
28
+ Trollop::die :instancetype, "is required but not specified" unless opts[:instancetype]
29
+ Trollop::die :s3bucket, "is required but not specified" unless opts[:s3bucket]
30
+
31
+ gem_root = File.expand_path '../..', __FILE__
32
+
33
+ config = Config.new.environment opts[:environment]
34
+
35
+ command = 'simple_deploy create' +
36
+ ' -e ' + opts[:environment] +
37
+ ' -n ' + opts[:name] +
38
+ ' -t '+ gem_root + '/cloud_formation_templates/instance_group_gatling.json' +
39
+ ' -a Description="EC2 Gatling Instance"' +
40
+ ' -a KeyName=' + extract_keyname(config['key']) +
41
+ ' -a AmiId=' + opts[:ami] +
42
+ ' -a S3BucketName=' + opts[:s3bucket] +
43
+ ' -a InstanceType=' + opts[:instancetype]
44
+
45
+ Shared::pretty_print `#{command}`
46
+ end
47
+
48
+ def extract_keyname(fullpath_keypair)
49
+ a = fullpath_keypair.split('/')
50
+ a[a.length-1].sub('.pem', '')
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,91 @@
1
+ require 'trollop'
2
+ require 'aws-sdk'
3
+
4
+ module SimplePerf
5
+ module CLI
6
+ class DeployGatling
7
+ include Shared
8
+
9
+ def execute
10
+ opts = Trollop::options do
11
+ version SimplePerf::VERSION
12
+ banner <<-EOS
13
+
14
+ Deploys Gatling test assets (user-files directory) to EC2 Gatling instances.
15
+
16
+ Usage:
17
+ simple_perf deploy_gatling -e ENVIRONMENT -n STACK_NAME
18
+ EOS
19
+ opt :help, "Display Help"
20
+ opt :environment, "Set the target environment", :type => :string
21
+ opt :name, "Stack name to manage", :type => :string
22
+ end
23
+ Trollop::die :environment, "is required but not specified" unless opts[:environment]
24
+ Trollop::die :name, "is required but not specified" unless opts[:name]
25
+
26
+ file_name = 'user-files.tar.gz'
27
+
28
+ `#{'COPYFILE_DISABLE=1; export COPYFILE_DISABLE; gnutar cvzf user-files.tar.gz user-files/'}`
29
+
30
+ config = Config.new.environment opts[:environment]
31
+
32
+ ENV['SIMPLE_DEPLOY_SSH_KEY'] = config['key']
33
+ ENV['SIMPLE_DEPLOY_SSH_USER'] = config['user']
34
+
35
+ AWS.config(
36
+ :access_key_id => config['access_key'],
37
+ :secret_access_key => config['secret_key'])
38
+
39
+ #TODO - This is a bad idea...there could be multiple stacks with s3 in the name...fix later
40
+ command = 'simple_deploy list' +
41
+ ' -e ' + opts[:environment] +
42
+ ' | grep s3'
43
+ bucket_stack = `#{command}`
44
+
45
+ command = 'simple_deploy outputs' +
46
+ ' -e ' + opts[:environment] +
47
+ ' -n ' + bucket_stack
48
+ bucket_name = `#{command}`
49
+ bucket_name = bucket_name.split(' ')[1]
50
+
51
+ if(config['region'] == 'us-east-1')
52
+ s3_endpoint = 's3.amazonaws.com'
53
+ else
54
+ s3_endpoint = "s3-#{config['region']}.amazonaws.com"
55
+ end
56
+
57
+ s3 = AWS::S3.new(:s3_endpoint => s3_endpoint)
58
+
59
+ # create a bucket
60
+ #b = s3.buckets.create(bucket_name)
61
+
62
+ # use existing s3 bucket
63
+ b = s3.buckets[bucket_name] # no request made
64
+
65
+ # upload a file
66
+ basename = File.basename(file_name)
67
+ o = b.objects[basename]
68
+ o.write(:file => file_name)
69
+
70
+ puts "Uploaded #{file_name} to:"
71
+ puts o.public_url
72
+
73
+ command = 'simple_deploy execute' +
74
+ ' -e ' + opts[:environment] +
75
+ ' -n ' + opts[:name] +
76
+ ' -c "~/sync_gatling_files.sh"' +
77
+ ' -l debug'
78
+
79
+ Shared::pretty_print `#{command}`
80
+
81
+ command = 'simple_deploy execute' +
82
+ ' -e ' + opts[:environment] +
83
+ ' -n ' + opts[:name] +
84
+ ' -c "cd ~/gatling_test_files; tar xvfz "' + file_name +
85
+ ' -l debug'
86
+
87
+ Shared::pretty_print `#{command}`
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,40 @@
1
+ require 'trollop'
2
+
3
+ module SimplePerf
4
+ module CLI
5
+ class StartGatling
6
+ include Shared
7
+
8
+ def execute
9
+ opts = Trollop::options do
10
+ version SimplePerf::VERSION
11
+ banner <<-EOS
12
+
13
+ Starts Gatling java processes.
14
+
15
+ Usage:
16
+ simple_perf start_gatling -e ENVIRONMENT -n STACK_NAME
17
+ EOS
18
+ opt :help, "Display Help"
19
+ opt :environment, "Set the target environment", :type => :string
20
+ opt :name, "Stack name to manage", :type => :string
21
+ end
22
+ Trollop::die :environment, "is required but not specified" unless opts[:environment]
23
+ Trollop::die :name, "is required but not specified" unless opts[:name]
24
+
25
+ config = Config.new.environment opts[:environment]
26
+
27
+ ENV['SIMPLE_DEPLOY_SSH_KEY'] = config['key']
28
+ ENV['SIMPLE_DEPLOY_SSH_USER'] = config['user']
29
+
30
+ command = 'simple_deploy execute' +
31
+ ' -e ' + opts[:environment] +
32
+ ' -n ' + opts[:name] +
33
+ ' -c "cd ~/gatling_test_files; nohup ./gatling.sh < input > gatling.log &"' +
34
+ ' -l debug'
35
+
36
+ Shared::pretty_print `#{command}`
37
+ end
38
+ end
39
+ end
40
+ end
@@ -12,6 +12,9 @@ require 'simple_perf/cli/status'
12
12
  require 'simple_perf/cli/results'
13
13
  require 'simple_perf/cli/update'
14
14
  require 'simple_perf/cli/chaos'
15
+ require 'simple_perf/cli/create_gatling'
16
+ require 'simple_perf/cli/deploy_gatling'
17
+ require 'simple_perf/cli/start_gatling'
15
18
 
16
19
  module SimplePerf
17
20
  module CLI
@@ -21,12 +24,18 @@ module SimplePerf
21
24
  case cmd
22
25
  when 'start'
23
26
  CLI::Start.new.execute
27
+ when 'start_gatling'
28
+ CLI::StartGatling.new.execute
24
29
  when 'stop'
25
30
  CLI::Stop.new.execute
26
31
  when 'deploy'
27
32
  CLI::Deploy.new.execute
33
+ when 'deploy_gatling'
34
+ CLI::DeployGatling.new.execute
28
35
  when 'create'
29
36
  CLI::Create.new.execute
37
+ when 'create_gatling'
38
+ CLI::CreateGatling.new.execute
30
39
  when 'create_bucket'
31
40
  CLI::CreateBucket.new.execute
32
41
  when 'destroy'
@@ -40,13 +49,13 @@ module SimplePerf
40
49
  when 'chaos'
41
50
  CLI::Chaos.new.execute
42
51
  when '-h'
43
- puts "simple_perf [start|stop|deploy|create|create_bucket|destroy|status|results|update|chaos] [options]"
52
+ puts "simple_perf [start|start_gatling|stop|deploy|deploy_gatling|create|create_gatling|create_bucket|destroy|status|results|update|chaos] [options]"
44
53
  puts "Append -h for help on specific subcommand."
45
54
  when '-v'
46
55
  puts SimplePerf::VERSION
47
56
  else
48
57
  puts "Unknown command: '#{cmd}'."
49
- puts "simple_perf [start|stop|deploy|create|create_bucket|destroy|status|results|update|chaos] [options]"
58
+ puts "simple_perf [start|start_gatling|stop|deploy|deploy_gatling|create|create_gatling|create_bucket|destroy|status|results|update|chaos] [options]"
50
59
  puts "Append -h for help on specific subcommand."
51
60
  exit 1
52
61
  end
@@ -0,0 +1,300 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Description": "Simple Perf Instance Group for Gatling",
4
+
5
+ "Parameters": {
6
+
7
+ "MaximumInstances": {
8
+ "Type": "String",
9
+ "Description": "Maximum number of app instances",
10
+ "Default": "1"
11
+ },
12
+ "MinimumInstances": {
13
+ "Type": "String",
14
+ "Description": "Minimum number of app instances",
15
+ "Default": "1"
16
+ },
17
+ "AmiId" : {
18
+ "Description" : "Ami to provision",
19
+ "Type" : "String"
20
+ },
21
+ "KeyName": {
22
+ "Description": "Name of EC2 key pair to use",
23
+ "Type": "String"
24
+ },
25
+ "InstanceType" : {
26
+ "Description" : "EC2 instance type",
27
+ "Type" : "String",
28
+ "Default" : "m1.medium",
29
+ "AllowedValues" : [ "m1.small","m1.medium","m1.large","m1.xlarge",
30
+ "m3.xlarge", "m3.2xlarge", "c1.xlarge" ],
31
+ "ConstraintDescription" : "must be a valid EC2 instance type."
32
+ },
33
+ "S3BucketName": {
34
+ "Description": "Name of S3 bucket",
35
+ "Type": "String"
36
+ },
37
+ "Abort": {
38
+ "Description": "Should the entire deployment be aborted if bootstraping fails?",
39
+ "Type": "String",
40
+ "Default": "yes",
41
+ "AllowedValues": [ "yes", "no" ],
42
+ "ConstraintDescription": "yes or no"
43
+ }
44
+ },
45
+
46
+ "Mappings": {
47
+ "BootstrapSettingMap": {
48
+ "abort": { "yes": "$?", "no": "0" }
49
+ },
50
+ "S3Map": {
51
+ "us-east-1": { "s3": "s3:/",
52
+ "http": "http://s3.amazonaws.com",
53
+ "https": "https://s3.amazonaws.com",
54
+ "endpoint": "s3.amazonaws.com"
55
+ },
56
+ "us-west-1": { "s3": "s3:/",
57
+ "http": "http://s3-us-west-1.amazonaws.com",
58
+ "https": "https://s3-us-west-1.amazonaws.com",
59
+ "endpoint": "s3-us-west-1.amazonaws.com"
60
+ },
61
+ "us-west-2": { "s3": "s3:/",
62
+ "http": "http://s3-us-west-2.amazonaws.com",
63
+ "https": "https://s3-us-west-2.amazonaws.com",
64
+ "endpoint": "s3-us-west-2.amazonaws.com"
65
+ }
66
+ }
67
+ },
68
+
69
+ "Resources": {
70
+ "User": {
71
+ "Type": "AWS::IAM::User",
72
+ "Properties": {
73
+ "Path": "/",
74
+ "Policies": [{
75
+ "PolicyName": "user_resource_access",
76
+ "PolicyDocument": {
77
+ "Statement":[
78
+ {
79
+ "Effect": "Allow",
80
+ "Action": "cloudformation:DescribeStackResource",
81
+ "Resource": "*"
82
+ },
83
+ {
84
+ "Effect": "Allow",
85
+ "Action": ["s3:ListAllMyBuckets"],
86
+ "Resource": "arn:aws:s3:::*"
87
+ },
88
+ {
89
+ "Effect": "Allow",
90
+ "Action": ["s3:*"],
91
+ "Resource": [ { "Fn::Join": [ "", [ "arn:aws:s3:::",
92
+ { "Ref": "S3BucketName" } ] ] },
93
+ { "Fn::Join": [ "", [ "arn:aws:s3:::",
94
+ { "Ref": "S3BucketName" }, "/*" ] ] }
95
+ ]
96
+ }
97
+ ]
98
+
99
+ }
100
+ }]
101
+ }
102
+ },
103
+
104
+ "UserKey": {
105
+ "Type": "AWS::IAM::AccessKey",
106
+ "Properties": {
107
+ "UserName": {"Ref": "User"}
108
+ }
109
+ },
110
+
111
+ "Instances": {
112
+ "Type": "AWS::AutoScaling::AutoScalingGroup",
113
+ "Properties": {
114
+ "AvailabilityZones": { "Fn::GetAZs": "" },
115
+ "LaunchConfigurationName": { "Ref": "InstanceLaunchConfig" },
116
+ "MaxSize": { "Ref": "MaximumInstances" },
117
+ "MinSize": { "Ref": "MinimumInstances" },
118
+ "Tags": [ {
119
+ "Key": "Name",
120
+ "Value": { "Ref": "AWS::StackName" } ,
121
+ "PropagateAtLaunch": "true" }
122
+ ]
123
+ }
124
+ },
125
+
126
+ "InstanceLaunchConfig": {
127
+ "Type": "AWS::AutoScaling::LaunchConfiguration",
128
+ "Metadata": {
129
+
130
+ "AWS::CloudFormation::Init": {
131
+
132
+ "configSets": {
133
+ "default": [ "base", "s3cmd", "gatling" ]
134
+ },
135
+
136
+ "base": {
137
+
138
+ "files": {
139
+ "/etc/yum.repos.d/intu-packages.repo": {
140
+ "content": { "Fn::Join": [ "", [
141
+ "[intu-packages-", { "Ref": "AWS::Region" }, "]\n",
142
+ "name=Intuit Custom RPM Packages\n",
143
+ "baseurl=",
144
+ { "Fn::FindInMap": [ "S3Map", { "Ref": "AWS::Region" }, "http" ] },
145
+ "/intu-packages-", { "Ref": "AWS::Region" }, "/rhel/6/x86_64\n",
146
+ "gpgcheck=0\n",
147
+ "enabled=1\n"
148
+ ] ] },
149
+ "owner": "root",
150
+ "group": "root",
151
+ "mode": "000644"
152
+ }
153
+
154
+ }
155
+
156
+ },
157
+
158
+ "s3cmd": {
159
+
160
+ "files": {
161
+
162
+ "/home/ec2-user/.s3cfg": {
163
+ "content": { "Fn::Join": ["", [
164
+ "access_key = ", { "Ref": "UserKey" }, "\n",
165
+ "secret_key = ", {"Fn::GetAtt": ["UserKey", "SecretAccessKey"]}, "\n"
166
+ ]]},
167
+ "mode" : "000400",
168
+ "owner" : "ec2-user",
169
+ "group" : "ec2-user"
170
+ },
171
+
172
+ "/root/.s3cfg": {
173
+ "content": { "Fn::Join": ["", [
174
+ "access_key = ", { "Ref": "UserKey" }, "\n",
175
+ "secret_key = ", {"Fn::GetAtt": ["UserKey", "SecretAccessKey"]}, "\n"
176
+ ]]},
177
+ "mode" : "000400",
178
+ "owner" : "ec2-user",
179
+ "group" : "ec2-user"
180
+ }
181
+
182
+ },
183
+
184
+ "packages": {
185
+ "yum": {
186
+ "s3cmd": []
187
+ }
188
+ }
189
+
190
+ },
191
+
192
+ "gatling": {
193
+
194
+ "files": {
195
+
196
+ "/home/ec2-user/sync_gatling_files.sh": {
197
+ "content": { "Fn::Join": [ "", [ "#!/bin/bash", "\n",
198
+ "mkdir -p ~/gatling_test_files", "\n",
199
+ "cd ~/gatling_test_files", "\n",
200
+ "s3cmd sync s3://",
201
+ { "Ref": "S3BucketName" },
202
+ " ." ] ] },
203
+ "owner": "ec2-user",
204
+ "group": "ec2-user",
205
+ "mode": "000770"
206
+ },
207
+
208
+ "/home/ec2-user/gatling_test_files/gatling.sh": {
209
+ "content": { "Fn::Join": [ "", [ "#!/bin/bash", "\n",
210
+ "export GATLING_HOME=/opt/gatling", "\n",
211
+ "$GATLING_HOME/bin/gatling.sh -df ~/gatling_test_files/user-files/data -sf ~/gatling_test_files/user-files/simulations", "\n" ] ] },
212
+ "owner": "ec2-user",
213
+ "group": "ec2-user",
214
+ "mode": "000770"
215
+ },
216
+
217
+ "/home/ec2-user/gatling_test_files/input": {
218
+ "content": { "Fn::Join": [ "", [ "GatlingSimulation", "\n",
219
+ "EWLB", "\n" ] ] },
220
+ "owner": "ec2-user",
221
+ "group": "ec2-user",
222
+ "mode": "000770"
223
+ }
224
+
225
+ },
226
+
227
+ "packages": {
228
+ "yum": {
229
+ "intu-gatling": [ "1.5.1" ]
230
+ }
231
+ }
232
+
233
+ }
234
+ }
235
+ },
236
+
237
+ "Properties": {
238
+ "KeyName" : { "Ref": "KeyName" },
239
+ "ImageId" : { "Ref" : "AmiId" },
240
+ "InstanceType": { "Ref": "InstanceType" },
241
+ "SecurityGroups": [ { "Ref": "InstancesSecurityGroup" } ],
242
+ "UserData": { "Fn::Base64": { "Fn::Join": ["", [
243
+ "#!/bin/bash\n",
244
+
245
+ "chmod 644 /etc/resolv.conf", "\n",
246
+
247
+ "if [ -f /etc/yum.repos.d/intu-packages-us-west-1.repo ]; then", "\n",
248
+ "rm -f /etc/yum.repos.d/intu-packages-us-west-1.repo", "\n",
249
+ "fi", "\n",
250
+
251
+ "/opt/aws/bin/cfn-init ",
252
+ " -s ", { "Ref": "AWS::StackName" },
253
+ " -r InstanceLaunchConfig",
254
+ " --region=", { "Ref": "AWS::Region" },
255
+ " --access-key=", { "Ref": "UserKey" },
256
+ " --secret-key=", { "Fn::GetAtt": ["UserKey", "SecretAccessKey"] }, "\n",
257
+
258
+ "runuser -c \"chown -R ec2-user:ec2-user /opt/gatling\" root", "\n",
259
+ "runuser -c \"chown -R ec2-user:ec2-user /home/ec2-user/gatling_test_files\" root", "\n",
260
+
261
+ "/opt/aws/bin/cfn-signal -e ",
262
+ { "Fn::FindInMap": [ "BootstrapSettingMap", "abort", { "Ref": "Abort" } ] },
263
+ " '", { "Ref": "InstancesWaitHandle" }, "'\n"
264
+ ]]}}
265
+ }
266
+ },
267
+
268
+ "InstancesSecurityGroup": {
269
+ "Type": "AWS::EC2::SecurityGroup",
270
+ "Properties": {
271
+ "GroupDescription": "Security Group for the app the instance",
272
+ "SecurityGroupIngress": [
273
+ {
274
+ "IpProtocol" : "tcp",
275
+ "FromPort" : "22",
276
+ "ToPort" : "22",
277
+ "CidrIp" : "0.0.0.0/0"
278
+ }
279
+ ]
280
+ }
281
+ },
282
+
283
+ "InstancesWaitHandle": {
284
+ "Type": "AWS::CloudFormation::WaitConditionHandle",
285
+ "Properties": {}
286
+ },
287
+
288
+ "InstancesWaitCondition": {
289
+ "Type": "AWS::CloudFormation::WaitCondition",
290
+ "DependsOn": [ "InstanceLaunchConfig" ],
291
+ "Properties": {
292
+ "Handle": { "Ref": "InstancesWaitHandle" },
293
+ "Count": "1",
294
+ "Timeout": "900"
295
+ }
296
+ }
297
+
298
+ }
299
+
300
+ }
@@ -1,3 +1,3 @@
1
1
  module SimplePerf
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/simple_perf.gemspec CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |s|
7
7
  s.version = SimplePerf::VERSION
8
8
  s.authors = ["Jimmy Armitage"]
9
9
  s.email = ["mrjimmy410@gmail.com"]
10
- s.homepage = "http://www.example.com"
10
+ s.homepage = "https://github.com/intuit/simple_perf"
11
11
  s.summary = %q{I help with performance testing}
12
- s.description = %q{I am designed to control a JMeter army of AWS EC2 instances}
12
+ s.description = %q{I am designed to control a JMeter or Gatling army of AWS EC2 instances}
13
13
 
14
14
  s.rubyforge_project = "simple_perf"
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_perf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-04 00:00:00.000000000 Z
12
+ date: 2013-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -91,7 +91,7 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 1.9.5
94
- description: I am designed to control a JMeter army of AWS EC2 instances
94
+ description: I am designed to control a JMeter or Gatling army of AWS EC2 instances
95
95
  email:
96
96
  - mrjimmy410@gmail.com
97
97
  executables:
@@ -112,21 +112,25 @@ files:
112
112
  - lib/simple_perf/cli/chaos.rb
113
113
  - lib/simple_perf/cli/create.rb
114
114
  - lib/simple_perf/cli/create_bucket.rb
115
+ - lib/simple_perf/cli/create_gatling.rb
115
116
  - lib/simple_perf/cli/deploy.rb
117
+ - lib/simple_perf/cli/deploy_gatling.rb
116
118
  - lib/simple_perf/cli/destroy.rb
117
119
  - lib/simple_perf/cli/results.rb
118
120
  - lib/simple_perf/cli/shared.rb
119
121
  - lib/simple_perf/cli/start.rb
122
+ - lib/simple_perf/cli/start_gatling.rb
120
123
  - lib/simple_perf/cli/status.rb
121
124
  - lib/simple_perf/cli/stop.rb
122
125
  - lib/simple_perf/cli/update.rb
123
126
  - lib/simple_perf/cloud_formation_templates/instance_group.json
127
+ - lib/simple_perf/cloud_formation_templates/instance_group_gatling.json
124
128
  - lib/simple_perf/cloud_formation_templates/s3_bucket.json
125
129
  - lib/simple_perf/config.rb
126
130
  - lib/simple_perf/version.rb
127
131
  - simple_perf.gemspec
128
132
  - spec/spec_helper.rb
129
- homepage: http://www.example.com
133
+ homepage: https://github.com/intuit/simple_perf
130
134
  licenses: []
131
135
  post_install_message:
132
136
  rdoc_options: []