hugo 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe Hugo::Aws::Elb do
4
+ before(:each) do
5
+ mock_ec2
6
+ mock_elb
7
+ mock_rds
8
+
9
+ end
10
+
11
+ it "should create a new instance" do
12
+ @hugo_elb = Hugo::Aws::Elb.new(:name => "myserver").should be_true
13
+ @hugo_elb.save.should be_true
14
+ end
15
+ #
16
+ it "should return all" do
17
+ Hugo::Aws::Elb.all.length.should == 1
18
+ end
19
+ # #
20
+ it "should find elb instance" do
21
+ Hugo::Aws::Elb.find('test').should_not be_nil
22
+ end
23
+ #
24
+ it "should delete elb instance" do
25
+ Hugo::Aws::Elb.find('test').destroy.should_not be_nil
26
+ end
27
+
28
+ it "should add ec2 intance" do
29
+ Hugo::Aws::Elb.find('test').add('i-12345678').instances.length.should == 1
30
+ end
31
+
32
+ it "should remove ec2 instance" do
33
+ Hugo::Aws::Elb.find('test').remove('i-12345678').instances.length.should == 0
34
+ end
35
+
36
+ end
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+
3
+ describe Hugo::Aws::Rds do
4
+ before(:each) do
5
+ mock_ec2
6
+ mock_elb
7
+ mock_rds
8
+ end
9
+
10
+ it "should create a new instance" do
11
+ @hugo_rds = Hugo::Aws::Rds.new(:name => "myserver", :db => "mydb", :user => "user", :password => "password").should be_true
12
+ @hugo_rds.save.should be_true
13
+ end
14
+
15
+ it "should return all" do
16
+ Hugo::Aws::Rds.all.length.should == 1
17
+ end
18
+ #
19
+ it "should find rds instance" do
20
+ Hugo::Aws::Rds.find('test').should_not be_nil
21
+ end
22
+
23
+ it "should delete rds instance" do
24
+ Hugo::Aws::Rds.find('test').destroy
25
+ end
26
+
27
+ it "should provide uri" do
28
+ Hugo::Aws::Rds.find('test').uri.should_not be_nil
29
+ end
30
+
31
+ it "should find or create db security group" do
32
+ @rds = Hugo::Aws::Rds.find('i-12345678')
33
+ @rds.find_or_create_db_security_group('test', 'test description').should_not be_empty
34
+ end
35
+
36
+ it "should destroy a db security group" do
37
+ Hugo::Aws::Rds.find('i-12345678').destroy_db_security_group('test').should be_true
38
+ end
39
+
40
+ it "should authorize a ec2 security group" do
41
+ @rds = Hugo::Aws::Rds.find('i-12345678')
42
+ @rds.authorize_security_group('test', 'test', '12334').should_not be_empty
43
+ end
44
+ end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "Hugo Balancer" do
4
+ before(:each) do
5
+ mocks
6
+ end
7
+
8
+ it "should be valid" do
9
+ block = lambda do
10
+ cloud "my_cloud" do
11
+ balancer
12
+ end
13
+ end
14
+
15
+ lambda do
16
+ Hugo &block
17
+ end.should_not raise_error
18
+ end
19
+
20
+ it "should raise error for balancer block not wrapped in cloud block" do
21
+ block = lambda do
22
+ balancer "error" do end
23
+ end
24
+
25
+ lambda do
26
+ Hugo &block
27
+ end.should raise_error
28
+ end
29
+
30
+ it "should find or create balancer" do
31
+ lb = Hugo::Balancer.instance
32
+ lb.name "myserver"
33
+ lb.deploy.should be_a_kind_of(Hugo::Aws::Elb)
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,66 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "Hugo Database" do
4
+ before(:each) do
5
+ mocks
6
+ end
7
+
8
+ it "should be valid" do
9
+
10
+ block = lambda do
11
+ cloud "my_cloud" do
12
+ database "testapp" do
13
+ server "serverx"
14
+ user "test_user"
15
+ password "test_password"
16
+ end
17
+ end
18
+ end
19
+
20
+ lambda do
21
+ Hugo &block
22
+ end.should_not raise_error
23
+ end
24
+
25
+ it "should raise error for database block not wrapped in cloud block" do
26
+ block = lambda do
27
+ database "mydb" do end
28
+ end
29
+
30
+ lambda do
31
+ Hugo &block
32
+ end.should raise_error
33
+ end
34
+
35
+ it "should not raise error for database block wrapped in cloud block" do
36
+ block = lambda do
37
+ cloud "mycloud" do
38
+ database "mydb" do end
39
+ end
40
+ end
41
+
42
+ lambda do
43
+ Hugo &block
44
+ end.should be_true
45
+ end
46
+ end
47
+
48
+ describe Hugo::Database do
49
+ before(:each) do
50
+ mocks
51
+ end
52
+
53
+
54
+ it "should create a new rds instance" do
55
+
56
+ db = Hugo::Database.instance
57
+ db.server "myserver"
58
+ db.name "mydb"
59
+ db.user "admin"
60
+ db.password "test"
61
+ db.deploy.should be_a_kind_of(Hugo::Aws::Rds)
62
+ end
63
+
64
+
65
+ end
66
+
@@ -0,0 +1,54 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Hugo DSL" do
4
+ before(:each) do
5
+ mocks
6
+ end
7
+
8
+ it "should be valid" do
9
+ block = lambda {|a,b|}
10
+ lambda do
11
+ Hugo &block
12
+ end.should be_true
13
+ end
14
+
15
+
16
+ it "should be_true with cloud block" do
17
+ block = lambda do
18
+ cloud "my_cloud" do end
19
+ end
20
+
21
+ lambda do
22
+ Hugo &block
23
+ end.should be_true
24
+ end
25
+
26
+
27
+
28
+ it "should deploy infrastructure" do
29
+ block = lambda do
30
+
31
+ cloud "gmms" do
32
+ balancer
33
+
34
+ database "sentinel" do
35
+ server "jackhq"
36
+ user "admin"
37
+ password "mypassword"
38
+ end
39
+
40
+ app "sentinel" do
41
+ gem_list = [{:name => "rack"}]
42
+ end
43
+ end
44
+ end
45
+
46
+ lambda do
47
+ Hugo &block
48
+ end.should_not raise_error
49
+
50
+
51
+ end
52
+
53
+
54
+ end
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,116 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/hugo")
2
+
3
+ Bundler.require_env(:test) # get rspec and webrat in here
4
+
5
+
6
+ # require 'rubygems'
7
+ # require 'sinatra'
8
+ #require 'rack/test'
9
+ require 'spec'
10
+ require 'spec/autorun'
11
+ require 'spec/interop/test'
12
+
13
+ def mock_ssh
14
+ @mock_ssh = mock('Net::SSH')
15
+ Net::SSH.stub!(:start).and_return(@mock_ssh)
16
+ @mock_ssh.stub!(:exec).and_return("Works!")
17
+ end
18
+
19
+
20
+ def mock_ec2
21
+ @mock_ec2 = mock('AWS::EC2::Base')
22
+ instance = {"requestId"=>"e280b5aa-9b60-458f-b16f-96f97eb5e628", "reservationSet"=>
23
+ {"item"=>[{"reservationId"=>"r-ff5d8797", "groupSet"=>{"item"=>[{"groupId"=>"default"}]},
24
+ "instancesSet"=>{"item"=>[{"privateIpAddress"=>"10.210.43.6", "keyName"=>"ec2-keypair", "ramdiskId"=>"ari-0915f660", "productCodes"=>nil, "ipAddress"=>"174.129.63.98", "kernelId"=>"aki-5f15f636", "launchTime"=>"2009-11-29T13:20:48.000Z", "amiLaunchIndex"=>"0",
25
+ "imageId"=>"ami-1515f67c", "instanceType"=>"m1.small", "reason"=>nil, "placement"=>{"availabilityZone"=>"us-east-1c"},
26
+ "instanceId"=>"i-12345678", "privateDnsName"=>"domU-XXXX.compute-1.internal",
27
+ "dnsName"=>"ec2-XXX.compute-1.amazonaws.com", "monitoring"=>{"state"=>"enabled"},
28
+ "instanceState"=>{"name"=>"running", "code"=>"16"}}]}, "ownerId"=>"398217953086"}]}, "xmlns"=>"http://ec2.amazonaws.com/doc/2009-07-15/"}
29
+
30
+ @mock_ec2.stub!(:run_instances).and_return(instance)
31
+ @mock_ec2.stub!(:describe_instances).and_return(instance)
32
+ @mock_ec2.stub!(:terminate_instances).and_return(instance)
33
+
34
+ security_group = {"group_name"=>"test", "group_description"=>"test description"}
35
+ @mock_ec2.stub!(:create_security_groups).and_return(security_group)
36
+ @mock_ec2.stub!(:describe_security_groups).and_return(security_group)
37
+ @mock_ec2.stub!(:delete_security_group).and_return(security_group)
38
+
39
+ AWS::EC2::Base.stub!(:new).and_return(@mock_ec2)
40
+
41
+
42
+ end
43
+
44
+ def mock_elb
45
+ @mock_elb = mock('AWS::ELB::Base')
46
+ instance = {"DescribeLoadBalancersResult"=>
47
+ {"LoadBalancerDescriptions"=>
48
+ {"member"=>[
49
+ {"CreatedTime"=>"2009-11-27T17:23:31.890Z", "Listeners"=>
50
+ {"member"=>[
51
+ {"InstancePort"=>"8080", "Protocol"=>"HTTP", "LoadBalancerPort"=>"80"},
52
+ {"InstancePort"=>"8443", "Protocol"=>"TCP", "LoadBalancerPort"=>"443"}]},
53
+ "HealthCheck"=>{"HealthyThreshold"=>"10", "Timeout"=>"5", "UnhealthyThreshold"=>"2", "Interval"=>"30", "Target"=>"TCP:8080"},
54
+ "AvailabilityZones"=>{"member"=>["us-east-1c"]},
55
+ "DNSName"=>"test-611935247.us-east-1.elb.amazonaws.com",
56
+ "LoadBalancerName"=>"test",
57
+ "Instances"=>{"member"=>[]}}]}},
58
+ "ResponseMetadata"=>{"RequestId"=>"0ada795e-e1df-11de-950d-c1b3b9142192"}, "xmlns"=>"http://elasticloadbalancing.amazonaws.com/doc/2009-05-15/"}
59
+
60
+ @mock_elb.stub!(:create_load_balancer).and_return(instance)
61
+ @mock_elb.stub!(:describe_load_balancers).and_return(instance)
62
+ @mock_elb.stub!(:delete_load_balancer).and_return(instance)
63
+ @mock_elb.stub!(:register_instances_with_load_balancer).and_return(instance)
64
+ @mock_elb.stub!(:deregister_instances_from_load_balancer).and_return(instance)
65
+
66
+ AWS::ELB::Base.stub!(:new).and_return(@mock_elb)
67
+
68
+
69
+ end
70
+
71
+ def mock_rds
72
+ @mock_rds = mock('AWS::RDS::Base')
73
+ instance = { "DescribeDBInstancesResult" =>
74
+ { "DBInstances" =>
75
+ { "DBInstance" =>
76
+ { "InstanceCreateTime"=>"2009-11-08T15:01:32.490Z", "Endpoint"=> { "Port"=>"3306", "Address"=>"test.cwrzj6lxowfj.us-east-1.rds.amazonaws.com"},
77
+ "PreferredMaintenanceWindow"=>"sun:05:00-sun:09:00",
78
+ "DBName"=>"mydb",
79
+ "Engine"=>"mysql5.1", "MasterUsername"=>"user",
80
+ "DBInstanceClass"=>"db.m1.small", "DBInstanceStatus"=>"available",
81
+ "BackupRetentionPeriod"=>"1", "LatestRestorableTime"=>"2009-12-05T18:19:59Z",
82
+ "DBInstanceIdentifier"=>"myserver", "AllocatedStorage"=>"5",
83
+ "AvailabilityZone"=>"us-east-1c",
84
+ "DBSecurityGroups"=>{ "DBSecurityGroup"=>{"Status"=>"active", "DBSecurityGroupName"=>"default"}}, "DBParameterGroups"=>{"DBParameterGroup"=>{"DBParameterGroupName"=>"default.mysql5.1", "ParameterApplyStatus"=>"in-sync"}}, "PreferredBackupWindow"=>"03:00-05:00"
85
+ }
86
+ }
87
+ }
88
+ }
89
+
90
+ create_db_security_group = {"CreateDBSecurityGroupResult"=>{"DBSecurityGroup"=>{"OwnerId"=>"XXXXXXXXXXXXXXX", "DBSecurityGroupName"=>"beer", "IPRanges"=>nil, "DBSecurityGroupDescription"=>"A light beverage", "EC2SecurityGroups"=>nil}}, "ResponseMetadata"=>{"RequestId"=>"cc934f2f-f4a9-11de-ba6b-0ba63aeeddfe"}, "xmlns"=>"http://rds.amazonaws.com/admin/2009-10-16/"}
91
+ describe_db_security_groups = {"DescribeDBSecurityGroupsResult"=>{"DBSecurityGroups"=>{"DBSecurityGroup"=>{"OwnerId"=>"XXXXXXXXXXXX", "DBSecurityGroupName"=>"beer", "IPRanges"=>nil, "DBSecurityGroupDescription"=>"A light beverage", "EC2SecurityGroups"=>{"EC2SecurityGroup"=>{"Status"=>"authorized", "EC2SecurityGroupName"=>"default", "EC2SecurityGroupOwnerId"=>"XXXXXXXXXXXX"}}}}}, "ResponseMetadata"=>{"RequestId"=>"XXXXXXXXX"}, "xmlns"=>"http://rds.amazonaws.com/admin/2009-10-16/"}
92
+ db_authorize_security_group = {"AuthorizeDBSecurityGroupIngressResult"=>{"DBSecurityGroup"=>{"OwnerId"=>"XXXXXXXXXXXXXX", "DBSecurityGroupName"=>"beer", "IPRanges"=>nil, "DBSecurityGroupDescription"=>"A light beverage", "EC2SecurityGroups"=>{"EC2SecurityGroup"=>{"Status"=>"authorizing", "EC2SecurityGroupName"=>"default", "EC2SecurityGroupOwnerId"=>"XXXXXXXXXX"}}}}, "ResponseMetadata"=>{"RequestId"=>"5920e8b0-f4aa-11de-8dc1-73435d6ae588"}, "xmlns"=>"http://rds.amazonaws.com/admin/2009-10-16/"}
93
+ delete_db_security_group = {"ResponseMetadata"=>{"RequestId"=>"2e4f133b-f4ac-11de-bce4-4f8690d51058"}, "xmlns"=>"http://rds.amazonaws.com/admin/2009-10-16/"}
94
+
95
+ @mock_rds.stub!(:create_db_instance).and_return(instance)
96
+ @mock_rds.stub!(:describe_db_instances).and_return(instance)
97
+ @mock_rds.stub!(:delete_db_instance).and_return(instance)
98
+ @mock_rds.stub!(:create_db_security_group).and_return(create_db_security_group)
99
+ @mock_rds.stub!(:authorize_db_security_group).and_return(db_authorize_security_group)
100
+ @mock_rds.stub!(:delete_db_security_group).and_return(delete_db_security_group)
101
+ @mock_rds.stub!(:describe_db_security_groups).and_return(describe_db_security_groups)
102
+
103
+ AWS::RDS::Base.stub!(:new).and_return(@mock_rds)
104
+
105
+ end
106
+
107
+ def mocks
108
+ mock_ssh
109
+ mock_ec2
110
+ mock_rds
111
+ mock_elb
112
+ end
113
+
114
+
115
+
116
+
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hugo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Wilson
8
+ - Barrett Little
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-01-27 00:00:00 -05:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: A easy to understand DSL that makes it dirt simple to deploy to the cloud.
18
+ email: tom@jackhq.com
19
+ executables:
20
+ - autospec
21
+ - ec2-gem-example.rb
22
+ - ec2-gem-profile.rb
23
+ - ec2sh
24
+ - edit_json.rb
25
+ - prettify_json.rb
26
+ - setup.rb
27
+ - spec
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - .DS_Store
34
+ - .gitignore
35
+ - Gemfile
36
+ - Rakefile
37
+ - VERSION
38
+ - bin/autospec
39
+ - bin/ec2-gem-example.rb
40
+ - bin/ec2-gem-profile.rb
41
+ - bin/ec2sh
42
+ - bin/setup.rb
43
+ - bin/spec
44
+ - config/hugo.yml.example
45
+ - example/myhugo.rb
46
+ - lib/.DS_Store
47
+ - lib/hugo.old
48
+ - lib/hugo.rb
49
+ - lib/hugo/.DS_Store
50
+ - lib/hugo/app.rb
51
+ - lib/hugo/aws/ec2.rb
52
+ - lib/hugo/aws/elb.rb
53
+ - lib/hugo/aws/rds.rb
54
+ - lib/hugo/balancer.rb
55
+ - lib/hugo/cloud.rb
56
+ - lib/hugo/database.rb
57
+ - lib/hugo/mixin/params_validate.rb
58
+ - readme.md
59
+ - spec/.DS_Store
60
+ - spec/lib/hugo/app_spec.rb
61
+ - spec/lib/hugo/aws/ec2_spec.rb
62
+ - spec/lib/hugo/aws/elb_spec.rb
63
+ - spec/lib/hugo/aws/rds_spec.rb
64
+ - spec/lib/hugo/balancer_spec.rb
65
+ - spec/lib/hugo/database_spec.rb
66
+ - spec/lib/hugo_spec.rb
67
+ - spec/spec.opts
68
+ - spec/spec_helper.rb
69
+ - vendor/gems/cache/amazon-ec2-0.7.9.gem
70
+ - vendor/gems/cache/json-1.2.0.gem
71
+ - vendor/gems/cache/net-ssh-2.0.17.gem
72
+ - vendor/gems/cache/rspec-1.2.9.gem
73
+ - vendor/gems/cache/xml-simple-1.0.12.gem
74
+ has_rdoc: true
75
+ homepage: http://github.com/twilson63/hugo
76
+ licenses: []
77
+
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --charset=UTF-8
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: "0"
94
+ version:
95
+ requirements: []
96
+
97
+ rubyforge_project:
98
+ rubygems_version: 1.3.5
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Deploy Your Rack Apps to Cloud
102
+ test_files:
103
+ - spec/lib/hugo/app_spec.rb
104
+ - spec/lib/hugo/aws/ec2_spec.rb
105
+ - spec/lib/hugo/aws/elb_spec.rb
106
+ - spec/lib/hugo/aws/rds_spec.rb
107
+ - spec/lib/hugo/balancer_spec.rb
108
+ - spec/lib/hugo/database_spec.rb
109
+ - spec/lib/hugo_spec.rb
110
+ - spec/spec_helper.rb