openstudio-aws 0.1.7 → 0.1.8

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -13
  3. data/lib/openstudio-aws.rb +9 -7
  4. data/lib/openstudio/aws/aws.rb +53 -40
  5. data/lib/openstudio/aws/config.rb +0 -1
  6. data/lib/openstudio/aws/version.rb +2 -2
  7. data/lib/openstudio/lib/ami_list.rb +79 -0
  8. data/lib/openstudio/lib/openstudio_aws_instance.rb +138 -0
  9. data/lib/openstudio/lib/openstudio_aws_logger.rb +61 -0
  10. data/lib/openstudio/lib/openstudio_aws_methods.rb +232 -0
  11. data/lib/openstudio/lib/openstudio_aws_wrapper.rb +315 -0
  12. data/lib/openstudio/lib/os-aws.rb +77 -351
  13. data/spec/aws_instances/aws_spec_api.rb +70 -0
  14. data/spec/openstudio-aws/ami_list_spec.rb +37 -0
  15. data/spec/openstudio-aws/aws_methods_spec.rb +26 -0
  16. data/spec/openstudio-aws/lib_spec.rb +48 -0
  17. data/spec/reports/SPEC-OpenStudio-Aws-Aws-create-a-new-instance.xml +43 -0
  18. data/spec/reports/SPEC-OpenStudio-Aws-Aws-workers-before-server.xml +9 -0
  19. data/spec/reports/SPEC-OpenStudio-Aws-Aws.xml +7 -0
  20. data/spec/reports/SPEC-OpenStudio-Aws-Config-create-a-new-config.0.xml +9 -0
  21. data/spec/reports/SPEC-OpenStudio-Aws-Config-create-a-new-config.xml +9 -0
  22. data/spec/reports/SPEC-OpenStudio-Aws-Config.0.xml +7 -0
  23. data/spec/reports/SPEC-OpenStudio-Aws-Config.xml +7 -0
  24. data/spec/reports/SPEC-OpenStudioAmis-version-1.0.xml +13 -0
  25. data/spec/reports/SPEC-OpenStudioAmis-version-1.xml +13 -0
  26. data/spec/reports/SPEC-OpenStudioAmis.0.xml +7 -0
  27. data/spec/reports/SPEC-OpenStudioAmis.xml +7 -0
  28. data/spec/reports/SPEC-OpenStudioAwsMethods-processors.0.xml +11 -0
  29. data/spec/reports/SPEC-OpenStudioAwsMethods-processors.xml +11 -0
  30. data/spec/reports/SPEC-OpenStudioAwsMethods.0.xml +7 -0
  31. data/spec/reports/SPEC-OpenStudioAwsMethods.xml +7 -0
  32. data/spec/reports/SPEC-OpenStudioAwsWrapper-authenticated-session-availability.0.xml +11 -0
  33. data/spec/reports/SPEC-OpenStudioAwsWrapper-authenticated-session-availability.xml +11 -0
  34. data/spec/reports/SPEC-OpenStudioAwsWrapper-authenticated-session-new-instance.0.xml +9 -0
  35. data/spec/reports/SPEC-OpenStudioAwsWrapper-authenticated-session-new-instance.xml +9 -0
  36. data/spec/reports/SPEC-OpenStudioAwsWrapper-authenticated-session.0.xml +7 -0
  37. data/spec/reports/SPEC-OpenStudioAwsWrapper-authenticated-session.xml +7 -0
  38. data/spec/reports/SPEC-OpenStudioAwsWrapper-unauthenticated-session.0.xml +9 -0
  39. data/spec/reports/SPEC-OpenStudioAwsWrapper-unauthenticated-session.xml +9 -0
  40. data/spec/reports/SPEC-OpenStudioAwsWrapper.0.xml +7 -0
  41. data/spec/reports/SPEC-OpenStudioAwsWrapper.xml +7 -0
  42. metadata +70 -10
  43. data/lib/openstudio/aws/send_data.rb +0 -42
  44. data/spec/openstudio-aws/aws_spec.rb +0 -53
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenStudio::Aws::Aws do
4
+ context "create a new instance" do
5
+ before(:all) do
6
+ @config = OpenStudio::Aws::Config.new
7
+ @aws = OpenStudio::Aws::Aws.new
8
+ end
9
+
10
+ it "should create a new instance" do
11
+ @aws.should_not be_nil
12
+ end
13
+
14
+ it "should ask the user to create a new config file" do
15
+ end
16
+
17
+ it "should create a server" do
18
+ # use the default instance type
19
+ options = {instance_type: "t1.micro", image_id: "ami-fb301292"}
20
+
21
+ #options = {instance_type: "m1.small" }
22
+ @aws.create_server(options)
23
+ expect(@aws.os_aws.server).not_to be_nil
24
+ end
25
+
26
+ it "should create a 1 worker" do
27
+ options = {instance_type: "t1.micro", image_id: "ami-21301248"}
28
+ #options = {instance_type: "m1.small" }
29
+ #server_json[:instance_type] = "m2.4xlarge"
30
+ #server_json[:instance_type] = "m2.2xlarge"
31
+ #server_json[:instance_type] = "t1.micro"
32
+
33
+ @aws.create_workers(1, options)
34
+
35
+ expect(@aws.os_aws.workers).to have(1).thing
36
+ expect(@aws.os_aws.workers[0].data[:dns]).not_to be_nil
37
+ end
38
+
39
+ it "should be able to connect a worker to an existing server" do
40
+ options = {instance_type: "t1.micro", image_id: "ami-a9e4ccc0"}
41
+
42
+ # will require a new @aws class--but attached to same group_uuid
43
+ @config = OpenStudio::Aws::Config.new
44
+ @aws_2 = OpenStudio::Aws::Aws.new
45
+
46
+ @aws_2.os_aws.find_server(@aws.os_aws.group_uuid)
47
+
48
+ expect(@aws.os_aws.server).not_to be_nil
49
+ end
50
+
51
+ it "should kill running instances" do
52
+ # how to test this?
53
+ end
54
+ end
55
+
56
+ context "workers before server" do
57
+ before(:all) do
58
+ @aws = OpenStudio::Aws::Aws.new
59
+ end
60
+
61
+ it "should not create any workers" do
62
+ expect { @aws.create_workers(5) }.to raise_error
63
+ end
64
+ end
65
+
66
+ context "larger cluster" do
67
+
68
+ end
69
+
70
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenStudioAmis do
4
+
5
+ context "version 1" do
6
+ it "should default to an ami if nothing passed" do
7
+ a = OpenStudioAmis.new
8
+ amis = a.get_amis
9
+
10
+ expect(amis['server']).not_to be_nil
11
+ expect(amis['worker']).not_to be_nil
12
+ expect(amis['cc2worker']).not_to be_nil
13
+ end
14
+
15
+ it "should return specific amis if passed a version" do
16
+ a = OpenStudioAmis.new(1, "1.2.0", nil)
17
+
18
+ amis = a.get_amis
19
+
20
+ expect(amis['server']).to eq("ami-29e5cd40")
21
+ expect(amis['worker']).to eq("ami-a9e4ccc0")
22
+ expect(amis['cc2worker']).to eq("ami-5be4cc32")
23
+ end
24
+
25
+ it "should raise if passed an invalid version" do
26
+
27
+ end
28
+ end
29
+
30
+ context "version 2" do
31
+ it "should default the server version" do
32
+
33
+ end
34
+ end
35
+
36
+ end
37
+
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenStudioAwsMethods do
4
+ class DummyClass
5
+ end
6
+
7
+ before :each do
8
+ @dummy_class = DummyClass.new
9
+ @dummy_class.extend(OpenStudioAwsMethods)
10
+ end
11
+
12
+
13
+ context "processors" do
14
+ it "should default to 1 with a warning" do
15
+ r = @dummy_class.find_processors("unknowninstance")
16
+ expect(r).to eq(1)
17
+ end
18
+
19
+ it "should return known values for various instances" do
20
+ r = @dummy_class.find_processors("c3.8xlarge")
21
+ expect(r).to eq(16)
22
+ end
23
+
24
+ end
25
+ end
26
+
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe OpenStudioAwsWrapper do
4
+ context "unauthenticated session" do
5
+ it "should fail to authenticate" do
6
+ credentials = {:access_key_id => "blah", :secret_access_key => "key", :region => "us-east-1", :ssl_verify_peer => false}
7
+ @os_aws = OpenStudioAwsWrapper.new(credentials)
8
+ expect { @os_aws.describe_availability_zones }.to raise_exception
9
+ end
10
+ end
11
+
12
+ context "authenticated session" do
13
+ before :all do
14
+ config = OpenStudio::Aws::Config.new
15
+
16
+ credentials = {:access_key_id => config.access_key, :secret_access_key => config.secret_key, :region => "us-east-1", :ssl_verify_peer => false}
17
+ @os_aws = OpenStudioAwsWrapper.new(credentials)
18
+ end
19
+
20
+ context "new instance" do
21
+ it "should be created" do
22
+ expect { @os_aws }.not_to be_nil
23
+ end
24
+ end
25
+
26
+ context "availability" do
27
+ it "should describe the zones" do
28
+ resp = @os_aws.describe_availability_zones
29
+ expect { resp }.not_to be_nil
30
+ resp[:availability_zone_info].length.should eq(4)
31
+
32
+ resp[:availability_zone_info].inspect.should eq("[{:zone_name=>\"us-east-1a\", :state=>\"available\", :region_name=>\"us-east-1\", :messages=>[]}, {:zone_name=>\"us-east-1b\", :state=>\"available\", :region_name=>\"us-east-1\", :messages=>[]}, {:zone_name=>\"us-east-1c\", :state=>\"available\", :region_name=>\"us-east-1\", :messages=>[]}, {:zone_name=>\"us-east-1d\", :state=>\"available\", :region_name=>\"us-east-1\", :messages=>[]}]")
33
+
34
+ resp = @os_aws.describe_availability_zones_json
35
+ expect { resp }.not_to be_nil
36
+
37
+ end
38
+
39
+ it "should list number of instances" do
40
+ resp = @os_aws.describe_total_instances
41
+ expect { resp }.not_to be_nil
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+
48
+ end
@@ -0,0 +1,43 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Aws::Aws create a new instance" tests="6" time="767.414597" failures="0" errors="2" skipped="0">
3
+ <testcase name="OpenStudio::Aws::Aws create a new instance should create a new instance" time="0.00136">
4
+ </testcase>
5
+ <testcase name="OpenStudio::Aws::Aws create a new instance should ask the user to create a new config file" time="9.7e-05">
6
+ </testcase>
7
+ <testcase name="OpenStudio::Aws::Aws create a new instance should create a server" time="87.80665">
8
+ </testcase>
9
+ <testcase name="OpenStudio::Aws::Aws create a new instance should create a 1 worker" time="678.844013">
10
+ <failure type="NoMethodError" message="undefined method `ip' for #&lt;OpenStudioAwsInstance:0x007f926e1a2900&gt;">
11
+ undefined method `ip' for #&lt;OpenStudioAwsInstance:0x007f926e1a2900&gt; (NoMethodError)
12
+ NoMethodError:
13
+ undefined method `ip' for #&lt;OpenStudioAwsInstance:0x007f926e1a2900&gt;
14
+ ./lib/openstudio/lib/openstudio_aws_wrapper.rb:249:in `configure_server_and_workers'
15
+ ./lib/openstudio/aws/aws.rb:91:in `create_workers'
16
+ ./spec/aws_instances/aws_spec_api.rb:33:in `block (3 levels) in &lt;top (required)&gt;' </failure>
17
+ </testcase>
18
+ <testcase name="OpenStudio::Aws::Aws create a new instance should be able to connect a worker to an existing server" time="0.70369">
19
+ <failure type="ArgumentError" message="wrong number of arguments (5 for 6)">
20
+ wrong number of arguments (5 for 6) (ArgumentError)
21
+ ArgumentError:
22
+ wrong number of arguments (5 for 6)
23
+ ./lib/openstudio/lib/openstudio_aws_instance.rb:32:in `initialize'
24
+ ./lib/openstudio/lib/openstudio_aws_wrapper.rb:287:in `new'
25
+ ./lib/openstudio/lib/openstudio_aws_wrapper.rb:287:in `find_server'
26
+ ./spec/aws_instances/aws_spec_api.rb:46:in `block (3 levels) in &lt;top (required)&gt;' </failure>
27
+ </testcase>
28
+ <testcase name="OpenStudio::Aws::Aws create a new instance should kill running instances" time="0.000119">
29
+ </testcase>
30
+ <system-out>
31
+ {"timestamp":"1389645426","server":{"id":"i-ad7ba783","ip":"http://54.227.167.113","dns":"ec2-54-227-167-113.compute-1.amazonaws.com","procs":1}}
32
+
33
+ Server SSH Command:
34
+ ssh -i ec2_server_key.pem ubuntu@ec2-54-227-167-113.compute-1.amazonaws.com
35
+
36
+ Worker SSH Command:
37
+ ssh -i ec2_server_key.pem ubuntu@ec2-54-204-155-209.compute-1.amazonaws.com
38
+
39
+ Waiting for server/worker configurations
40
+ </system-out>
41
+ <system-err>
42
+ </system-err>
43
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Aws::Aws workers before server" tests="1" time="0.004718" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudio::Aws::Aws workers before server should not create any workers" time="0.000853">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Aws::Aws" tests="0" time="9.7e-05" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Aws::Config create a new config" tests="1" time="0.000619" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudio::Aws::Config create a new config should create a new instance" time="0.000477">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Aws::Config create a new config" tests="1" time="0.000624" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudio::Aws::Config create a new config should create a new instance" time="0.000456">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Aws::Config" tests="0" time="7.3e-05" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudio::Aws::Config" tests="0" time="7.6e-05" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAmis version 1" tests="2" time="0.013878" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAmis version 1 should default to an ami if nothing passed" time="0.007389">
4
+ </testcase>
5
+ <testcase name="OpenStudioAmis version 1 should return specific amis if passed a version" time="0.006203">
6
+ </testcase>
7
+ <system-out>
8
+ {"server"=&gt;"ami-29e5cd40", "worker"=&gt;"ami-a9e4ccc0", "cc2worker"=&gt;"ami-5be4cc32"}
9
+ {"server"=&gt;"ami-29e5cd40", "worker"=&gt;"ami-a9e4ccc0", "cc2worker"=&gt;"ami-5be4cc32"}
10
+ </system-out>
11
+ <system-err>
12
+ </system-err>
13
+ </testsuite>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAmis version 1" tests="2" time="0.020436" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAmis version 1 should default to an ami if nothing passed" time="0.012969">
4
+ </testcase>
5
+ <testcase name="OpenStudioAmis version 1 should return specific amis if passed a version" time="0.007211">
6
+ </testcase>
7
+ <system-out>
8
+ {"server"=&gt;"ami-29e5cd40", "worker"=&gt;"ami-a9e4ccc0", "cc2worker"=&gt;"ami-5be4cc32"}
9
+ {"server"=&gt;"ami-29e5cd40", "worker"=&gt;"ami-a9e4ccc0", "cc2worker"=&gt;"ami-5be4cc32"}
10
+ </system-out>
11
+ <system-err>
12
+ </system-err>
13
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAmis" tests="0" time="0.000103" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAmis" tests="0" time="0.000102" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsMethods processors" tests="2" time="0.000455" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAwsMethods processors should default to 1 with a warning" time="0.000173">
4
+ </testcase>
5
+ <testcase name="OpenStudioAwsMethods processors should return known values for various instances" time="0.000121">
6
+ </testcase>
7
+ <system-out>
8
+ </system-out>
9
+ <system-err>
10
+ </system-err>
11
+ </testsuite>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsMethods processors" tests="2" time="0.000467" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAwsMethods processors should default to 1 with a warning" time="0.000161">
4
+ </testcase>
5
+ <testcase name="OpenStudioAwsMethods processors should return known values for various instances" time="0.000126">
6
+ </testcase>
7
+ <system-out>
8
+ </system-out>
9
+ <system-err>
10
+ </system-err>
11
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsMethods" tests="0" time="0.000114" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsMethods" tests="0" time="8.6e-05" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsWrapper authenticated session availability" tests="2" time="0.871159" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAwsWrapper authenticated session availability should describe the zones" time="0.508461">
4
+ </testcase>
5
+ <testcase name="OpenStudioAwsWrapper authenticated session availability should list number of instances" time="0.362309">
6
+ </testcase>
7
+ <system-out>
8
+ </system-out>
9
+ <system-err>
10
+ </system-err>
11
+ </testsuite>
@@ -0,0 +1,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsWrapper authenticated session availability" tests="2" time="1.218258" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAwsWrapper authenticated session availability should describe the zones" time="0.655451">
4
+ </testcase>
5
+ <testcase name="OpenStudioAwsWrapper authenticated session availability should list number of instances" time="0.562497">
6
+ </testcase>
7
+ <system-out>
8
+ </system-out>
9
+ <system-err>
10
+ </system-err>
11
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsWrapper authenticated session new instance" tests="1" time="0.00027" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAwsWrapper authenticated session new instance should be created" time="0.000146">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsWrapper authenticated session new instance" tests="1" time="0.00028" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAwsWrapper authenticated session new instance should be created" time="0.000152">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsWrapper authenticated session" tests="0" time="0.000803" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsWrapper authenticated session" tests="0" time="0.000995" failures="0" errors="0" skipped="0">
3
+ <system-out>
4
+ </system-out>
5
+ <system-err>
6
+ </system-err>
7
+ </testsuite>
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuite name="OpenStudioAwsWrapper unauthenticated session" tests="1" time="0.864671" failures="0" errors="0" skipped="0">
3
+ <testcase name="OpenStudioAwsWrapper unauthenticated session should fail to authenticate" time="0.864502">
4
+ </testcase>
5
+ <system-out>
6
+ </system-out>
7
+ <system-err>
8
+ </system-err>
9
+ </testsuite>