appscale-tools 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +37 -0
- data/README +17 -0
- data/bin/appscale-add-keypair +15 -0
- data/bin/appscale-describe-instances +16 -0
- data/bin/appscale-remove-app +13 -0
- data/bin/appscale-reset-pwd +13 -0
- data/bin/appscale-run-instances +15 -0
- data/bin/appscale-terminate-instances +14 -0
- data/bin/appscale-upload-app +13 -0
- data/doc/AdvancedNode.html +163 -0
- data/doc/AppControllerClient.html +831 -0
- data/doc/AppEngineConfigException.html +165 -0
- data/doc/AppScaleException.html +165 -0
- data/doc/AppScaleTools.html +768 -0
- data/doc/BadCommandLineArgException.html +166 -0
- data/doc/BadConfigurationException.html +166 -0
- data/doc/CommonFunctions.html +2559 -0
- data/doc/EncryptionHelper.html +332 -0
- data/doc/GodInterface.html +443 -0
- data/doc/InfrastructureException.html +166 -0
- data/doc/Node.html +470 -0
- data/doc/NodeLayout.html +1297 -0
- data/doc/Object.html +539 -0
- data/doc/ParseArgs.html +268 -0
- data/doc/RemoteLogging.html +268 -0
- data/doc/SimpleNode.html +163 -0
- data/doc/UsageText.html +1204 -0
- data/doc/UserAppClient.html +993 -0
- data/doc/VMTools.html +1365 -0
- data/doc/bin/appscale-add-keypair.html +56 -0
- data/doc/bin/appscale-describe-instances.html +56 -0
- data/doc/bin/appscale-remove-app.html +56 -0
- data/doc/bin/appscale-reset-pwd.html +56 -0
- data/doc/bin/appscale-run-instances.html +56 -0
- data/doc/bin/appscale-terminate-instances.html +56 -0
- data/doc/bin/appscale-upload-app.html +56 -0
- data/doc/created.rid +21 -0
- data/doc/images/add.png +0 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/delete.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_blue.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/transparent.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +116 -0
- data/doc/js/darkfish.js +153 -0
- data/doc/js/jquery.js +18 -0
- data/doc/js/navigation.js +142 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/search.js +94 -0
- data/doc/js/search_index.js +1 -0
- data/doc/js/searcher.js +228 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/lib/app_controller_client_rb.html +60 -0
- data/doc/lib/appscale_tools_rb.html +88 -0
- data/doc/lib/common_functions_rb.html +78 -0
- data/doc/lib/custom_exceptions_rb.html +54 -0
- data/doc/lib/encryption_helper_rb.html +60 -0
- data/doc/lib/godinterface_rb.html +52 -0
- data/doc/lib/node_layout_rb.html +55 -0
- data/doc/lib/parse_args_rb.html +58 -0
- data/doc/lib/remote_log_rb.html +58 -0
- data/doc/lib/sshcopyid.html +174 -0
- data/doc/lib/usage_text_rb.html +58 -0
- data/doc/lib/user_app_client_rb.html +62 -0
- data/doc/lib/vm_tools_rb.html +62 -0
- data/doc/table_of_contents.html +496 -0
- data/lib/app_controller_client.rb +181 -0
- data/lib/appscale_tools.rb +403 -0
- data/lib/common_functions.rb +1467 -0
- data/lib/custom_exceptions.rb +25 -0
- data/lib/encryption_helper.rb +86 -0
- data/lib/godinterface.rb +152 -0
- data/lib/node_layout.rb +665 -0
- data/lib/parse_args.rb +415 -0
- data/lib/remote_log.rb +46 -0
- data/lib/sshcopyid +65 -0
- data/lib/usage_text.rb +144 -0
- data/lib/user_app_client.rb +245 -0
- data/lib/vm_tools.rb +549 -0
- data/test/tc_app_controller_client.rb +10 -0
- data/test/tc_appscale_add_keypair.rb +44 -0
- data/test/tc_appscale_describe_instances.rb +69 -0
- data/test/tc_appscale_remove_app.rb +128 -0
- data/test/tc_appscale_reset_pwd.rb +156 -0
- data/test/tc_appscale_run_instances.rb +48 -0
- data/test/tc_appscale_terminate_instances.rb +104 -0
- data/test/tc_appscale_upload_app.rb +166 -0
- data/test/tc_common_functions.rb +56 -0
- data/test/tc_encryption_helper.rb +10 -0
- data/test/tc_god_interface.rb +10 -0
- data/test/tc_node_layout.rb +93 -0
- data/test/tc_parse_args.rb +160 -0
- data/test/tc_user_app_client.rb +10 -0
- data/test/tc_vm_tools.rb +10 -0
- data/test/ts_all.rb +20 -0
- metadata +211 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'appscale_tools'
|
3
|
+
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'flexmock/test_unit'
|
7
|
+
|
8
|
+
|
9
|
+
class TestAppScaleAddKeypair < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@options_no_auto = {}
|
12
|
+
@options_w_auto = {"auto" => "true"}
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_not_having_ssh_copy_id_in_path
|
16
|
+
commonfunctions = flexmock(CommonFunctions)
|
17
|
+
commonfunctions.should_receive(:shell).with("which ssh-keygen").and_return("/usr/bin/ssh-keygen")
|
18
|
+
commonfunctions.should_receive(:shell).with("which ssh-copy-id").and_return("")
|
19
|
+
|
20
|
+
assert_raises(BadConfigurationException) {
|
21
|
+
AppScaleTools.add_keypair(@options_no_auto)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_not_having_expect_in_path
|
26
|
+
commonfunctions = flexmock(CommonFunctions)
|
27
|
+
commonfunctions.should_receive(:shell).with("which ssh-keygen").and_return("/usr/bin/ssh-keygen")
|
28
|
+
commonfunctions.should_receive(:shell).with("which ssh-copy-id").and_return("/usr/bin/ssh-copy-id")
|
29
|
+
commonfunctions.should_receive(:shell).with("which expect").and_return("")
|
30
|
+
|
31
|
+
assert_raises(BadConfigurationException) {
|
32
|
+
AppScaleTools.add_keypair(@options_w_auto)
|
33
|
+
}
|
34
|
+
|
35
|
+
# TODO(cgb) - add a test where auto isn't used - it shouldn't throw an error
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_usage_is_up_to_date
|
39
|
+
AppScaleTools::ADD_KEYPAIR_FLAGS.each { |flag|
|
40
|
+
assert_equal(true, AppScaleTools::ADD_KEYPAIR_USAGE.include?("-#{flag}"),
|
41
|
+
"No usage text for #{flag}.")
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'appscale_tools'
|
3
|
+
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'flexmock/test_unit'
|
7
|
+
|
8
|
+
|
9
|
+
class TestAppScaleDescribeInstances < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
kernel = flexmock(Kernel)
|
12
|
+
kernel.should_receive(:puts).and_return()
|
13
|
+
|
14
|
+
@key = "booscale"
|
15
|
+
@options = { "keyname" => @key }
|
16
|
+
|
17
|
+
# taken from the standard two node deployment
|
18
|
+
node1 = {
|
19
|
+
'public_ip' => 'public_ip1',
|
20
|
+
'private_ip' => 'private_ip1',
|
21
|
+
'jobs' => ['load_balancer', 'shadow', 'db_master', 'zookeeper', 'login', 'memcache', 'rabbitmq_master'],
|
22
|
+
'instance_id' => 'instance_id1',
|
23
|
+
'cloud' => 'cloud1',
|
24
|
+
'creation_time' => nil,
|
25
|
+
'destruction_time' => nil
|
26
|
+
}
|
27
|
+
|
28
|
+
@role_info = [node1]
|
29
|
+
|
30
|
+
commonfunctions = flexmock(CommonFunctions)
|
31
|
+
commonfunctions.should_receive(:read_file).
|
32
|
+
with(File.expand_path("~/.appscale/locations-#{@key}.json")).
|
33
|
+
and_return(JSON.dump(@role_info))
|
34
|
+
|
35
|
+
# mocks for get_role_info, which will return the node's state
|
36
|
+
appcontroller = flexmock('appcontroller')
|
37
|
+
appcontroller.should_receive(:get_role_info).and_return(@role_info)
|
38
|
+
appcontroller.should_receive(:status).and_return("ALL OK")
|
39
|
+
flexmock(AppControllerClient).should_receive(:new).
|
40
|
+
and_return(appcontroller)
|
41
|
+
|
42
|
+
commonfunctions.should_receive(:write_file).with(
|
43
|
+
File.expand_path("~/.appscale/locations-#{@key}.json"),
|
44
|
+
JSON.dump(@role_info)).and_return()
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_all_ok
|
48
|
+
commonfunctions = flexmock(CommonFunctions)
|
49
|
+
commonfunctions.should_receive(:get_secret_key).and_return("")
|
50
|
+
commonfunctions.should_receive(:get_head_node_ip).and_return("127.0.0.1")
|
51
|
+
|
52
|
+
flexmock(AppControllerClient).new_instances { |instance|
|
53
|
+
instance.should_receive(:get_all_public_ips).and_return(["127.0.0.1"])
|
54
|
+
instance.should_receive(:status).and_return("ALL OK")
|
55
|
+
}
|
56
|
+
|
57
|
+
instance_info = AppScaleTools.describe_instances(@options)
|
58
|
+
assert_equal(nil, instance_info[:error])
|
59
|
+
assert_equal(["ALL OK"], instance_info[:result])
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_usage_is_up_to_date
|
63
|
+
AppScaleTools::DESCRIBE_INSTANCES_FLAGS.each { |flag|
|
64
|
+
assert_equal(true,
|
65
|
+
AppScaleTools::DESCRIBE_INSTANCES_USAGE.include?("-#{flag}"),
|
66
|
+
"No usage text for #{flag}.")
|
67
|
+
}
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'appscale_tools'
|
3
|
+
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'flexmock/test_unit'
|
7
|
+
|
8
|
+
|
9
|
+
class TestAppScaleRemoveApp < Test::Unit::TestCase
|
10
|
+
def setup
|
11
|
+
@key = "appscale"
|
12
|
+
@options = {"appname" => "boo", "keyname" => @key}
|
13
|
+
|
14
|
+
@secret = "booooo"
|
15
|
+
@fake_yaml = {
|
16
|
+
:load_balancer => "127.0.0.1",
|
17
|
+
:shadow => "127.0.0.1",
|
18
|
+
:secret => @secret,
|
19
|
+
:db_master => "node-1",
|
20
|
+
:table => "cassandra",
|
21
|
+
:instance_id => "i-FOOBARZ"
|
22
|
+
}
|
23
|
+
yaml = flexmock(YAML)
|
24
|
+
yaml.should_receive(:load_file).and_return(@fake_yaml)
|
25
|
+
|
26
|
+
# taken from the standard two node deployment
|
27
|
+
node1 = {
|
28
|
+
'public_ip' => 'public_ip1',
|
29
|
+
'private_ip' => 'private_ip1',
|
30
|
+
'jobs' => ['load_balancer', 'shadow', 'db_master', 'zookeeper', 'login', 'memcache', 'rabbitmq_master'],
|
31
|
+
'instance_id' => 'instance_id1',
|
32
|
+
'cloud' => 'cloud1',
|
33
|
+
'creation_time' => nil,
|
34
|
+
'destruction_time' => nil
|
35
|
+
}
|
36
|
+
|
37
|
+
node2 = {
|
38
|
+
'public_ip' => 'public_ip2',
|
39
|
+
'private_ip' => 'private_ip2',
|
40
|
+
'jobs' => ['load_balancer', 'db_slave', 'memcache', 'rabbitmq_slave', 'appengine'],
|
41
|
+
'instance_id' => 'instance_id2',
|
42
|
+
'cloud' => 'cloud2',
|
43
|
+
'creation_time' => nil,
|
44
|
+
'destruction_time' => nil
|
45
|
+
}
|
46
|
+
|
47
|
+
@role_info = [node1, node2]
|
48
|
+
|
49
|
+
commonfunctions = flexmock(CommonFunctions)
|
50
|
+
commonfunctions.should_receive(:read_file).
|
51
|
+
with(File.expand_path("~/.appscale/locations-#{@key}.json")).
|
52
|
+
and_return(JSON.dump(@role_info))
|
53
|
+
commonfunctions.should_receive(:write_file).with(
|
54
|
+
File.expand_path("~/.appscale/locations-#{@key}.json"),
|
55
|
+
JSON.dump(@role_info)).and_return()
|
56
|
+
|
57
|
+
# mocks for get_role_info, which will return the node's state
|
58
|
+
appcontroller = flexmock('appcontroller')
|
59
|
+
appcontroller.should_receive(:get_role_info).and_return(@role_info)
|
60
|
+
appcontroller.should_receive(:get_userappserver_ip).and_return("127.0.0.1")
|
61
|
+
appcontroller.should_receive(:stop_app).and_return("true")
|
62
|
+
appcontroller.should_receive(:app_is_running?).and_return(true, false)
|
63
|
+
flexmock(AppControllerClient).should_receive(:new).
|
64
|
+
and_return(appcontroller)
|
65
|
+
|
66
|
+
kernel = flexmock(Kernel)
|
67
|
+
kernel.should_receive(:print).and_return()
|
68
|
+
kernel.should_receive(:puts).and_return()
|
69
|
+
kernel.should_receive(:sleep).and_return()
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_no_appname_given
|
73
|
+
options = {"keyname" => @key}
|
74
|
+
assert_raises(AppScaleException) {
|
75
|
+
AppScaleTools.remove_app(options)
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_user_cancels_removal
|
80
|
+
stdin = flexmock(STDIN)
|
81
|
+
stdin.should_receive(:gets).and_return("no\n")
|
82
|
+
|
83
|
+
assert_raises(AppScaleException) {
|
84
|
+
AppScaleTools.remove_app(@options)
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
def test_remove_app_that_doesnt_exist
|
89
|
+
stdin = flexmock(STDIN)
|
90
|
+
stdin.should_receive(:gets).and_return("yes\n")
|
91
|
+
|
92
|
+
file = flexmock(File)
|
93
|
+
file.should_receive(:exists?).and_return(true)
|
94
|
+
|
95
|
+
userappclient = flexmock(UserAppClient)
|
96
|
+
userappclient.new_instances { |instance|
|
97
|
+
instance.should_receive(:does_app_exist?).and_return(false)
|
98
|
+
}
|
99
|
+
|
100
|
+
assert_raises(AppEngineConfigException) {
|
101
|
+
AppScaleTools.remove_app(@options)
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_remove_app_that_does_exist
|
106
|
+
stdin = flexmock(STDIN)
|
107
|
+
stdin.should_receive(:gets).and_return("yes\n")
|
108
|
+
|
109
|
+
file = flexmock(File)
|
110
|
+
file.should_receive(:exists?).and_return(true)
|
111
|
+
|
112
|
+
userappclient = flexmock(UserAppClient)
|
113
|
+
userappclient.new_instances { |instance|
|
114
|
+
instance.should_receive(:does_app_exist?).and_return(true)
|
115
|
+
}
|
116
|
+
|
117
|
+
assert_nothing_raised(Exception) {
|
118
|
+
AppScaleTools.remove_app(@options)
|
119
|
+
}
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_usage_is_up_to_date
|
123
|
+
AppScaleTools::REMOVE_APP_FLAGS.each { |flag|
|
124
|
+
assert_equal(true, AppScaleTools::REMOVE_APP_USAGE.include?("-#{flag}"),
|
125
|
+
"No usage text for #{flag}.")
|
126
|
+
}
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,156 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'appscale_tools'
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
|
7
|
+
class TestAppScaleResetPassword < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
@keyname = "booscale"
|
10
|
+
@options = {"keyname" => @keyname}
|
11
|
+
|
12
|
+
kernel = flexmock(Kernel)
|
13
|
+
kernel.should_receive(:print).and_return()
|
14
|
+
kernel.should_receive(:puts).and_return()
|
15
|
+
|
16
|
+
stdout = flexmock(STDOUT)
|
17
|
+
stdout.should_receive(:flush).and_return()
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_appscale_not_running
|
21
|
+
file = flexmock(File)
|
22
|
+
file.should_receive(:exists?).and_return(true)
|
23
|
+
|
24
|
+
@secret = "booooo"
|
25
|
+
@fake_yaml = {:load_balancer => "",
|
26
|
+
:shadow => "127.0.0.1",
|
27
|
+
:secret => @secret,
|
28
|
+
:db_master => "node-1",
|
29
|
+
:table => "cassandra",
|
30
|
+
:instance_id => "i-FOOBARZ"}
|
31
|
+
yaml = flexmock(YAML)
|
32
|
+
yaml.should_receive(:load_file).and_return(@fake_yaml)
|
33
|
+
|
34
|
+
# taken from the standard two node deployment
|
35
|
+
node1 = {
|
36
|
+
'public_ip' => 'public_ip1',
|
37
|
+
'private_ip' => 'private_ip1',
|
38
|
+
'jobs' => ['shadow', 'db_master', 'zookeeper', 'login', 'memcache', 'rabbitmq_master'],
|
39
|
+
'instance_id' => 'instance_id1',
|
40
|
+
'cloud' => 'cloud1',
|
41
|
+
'creation_time' => nil,
|
42
|
+
'destruction_time' => nil
|
43
|
+
}
|
44
|
+
|
45
|
+
node2 = {
|
46
|
+
'public_ip' => 'public_ip2',
|
47
|
+
'private_ip' => 'private_ip2',
|
48
|
+
'jobs' => ['db_slave', 'memcache', 'rabbitmq_slave', 'appengine'],
|
49
|
+
'instance_id' => 'instance_id2',
|
50
|
+
'cloud' => 'cloud2',
|
51
|
+
'creation_time' => nil,
|
52
|
+
'destruction_time' => nil
|
53
|
+
}
|
54
|
+
|
55
|
+
@role_info = [node1, node2]
|
56
|
+
|
57
|
+
appcontroller = flexmock('appcontroller')
|
58
|
+
appcontroller.should_receive(:get_role_info).and_return(@role_info)
|
59
|
+
flexmock(AppControllerClient).should_receive(:new).and_return(appcontroller)
|
60
|
+
|
61
|
+
commonfunctions = flexmock(CommonFunctions)
|
62
|
+
commonfunctions.should_receive(:read_file).
|
63
|
+
with(File.expand_path("~/.appscale/locations-#{@keyname}.json")).
|
64
|
+
and_return(JSON.dump(@role_info))
|
65
|
+
commonfunctions.should_receive(:write_file).with(
|
66
|
+
File.expand_path("~/.appscale/locations-#{@keyname}.json"),
|
67
|
+
JSON.dump(@role_info)).and_return()
|
68
|
+
|
69
|
+
assert_raises(BadConfigurationException) {
|
70
|
+
AppScaleTools.reset_password(@options)
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_all_ok
|
75
|
+
file = flexmock(File)
|
76
|
+
file.should_receive(:exists?).and_return(true)
|
77
|
+
|
78
|
+
@secret = "booooo"
|
79
|
+
@fake_yaml = {:load_balancer => "127.0.0.1",
|
80
|
+
:shadow => "127.0.0.1",
|
81
|
+
:secret => @secret,
|
82
|
+
:db_master => "node-1",
|
83
|
+
:table => "cassandra",
|
84
|
+
:instance_id => "i-FOOBARZ"}
|
85
|
+
yaml = flexmock(YAML)
|
86
|
+
yaml.should_receive(:load_file).and_return(@fake_yaml)
|
87
|
+
|
88
|
+
# taken from the standard two node deployment
|
89
|
+
node1 = {
|
90
|
+
'public_ip' => 'public_ip1',
|
91
|
+
'private_ip' => 'private_ip1',
|
92
|
+
'jobs' => ['load_balancer', 'shadow', 'db_master', 'zookeeper', 'login', 'memcache', 'rabbitmq_master'],
|
93
|
+
'instance_id' => 'instance_id1',
|
94
|
+
'cloud' => 'cloud1',
|
95
|
+
'creation_time' => nil,
|
96
|
+
'destruction_time' => nil
|
97
|
+
}
|
98
|
+
|
99
|
+
node2 = {
|
100
|
+
'public_ip' => 'public_ip2',
|
101
|
+
'private_ip' => 'private_ip2',
|
102
|
+
'jobs' => ['load_balancer', 'db_slave', 'memcache', 'rabbitmq_slave', 'appengine'],
|
103
|
+
'instance_id' => 'instance_id2',
|
104
|
+
'cloud' => 'cloud2',
|
105
|
+
'creation_time' => nil,
|
106
|
+
'destruction_time' => nil
|
107
|
+
}
|
108
|
+
|
109
|
+
@role_info = [node1, node2]
|
110
|
+
|
111
|
+
commonfunctions = flexmock(CommonFunctions)
|
112
|
+
commonfunctions.should_receive(:read_file).
|
113
|
+
with(File.expand_path("~/.appscale/locations-#{@keyname}.json")).
|
114
|
+
and_return(JSON.dump(@role_info))
|
115
|
+
|
116
|
+
@user = "a@a.a"
|
117
|
+
@password = "aaaaaa"
|
118
|
+
|
119
|
+
stdin = flexmock(STDIN)
|
120
|
+
stdin.should_receive(:gets).and_return(@user + "\n", @password + "\n")
|
121
|
+
|
122
|
+
kernel = flexmock(Kernel)
|
123
|
+
kernel.should_receive(:system).with("stty -echo").and_return()
|
124
|
+
kernel.should_receive(:system).with("stty echo").and_return()
|
125
|
+
|
126
|
+
appcontroller = flexmock('appcontroller')
|
127
|
+
appcontroller.should_receive(:get_role_info).and_return(@role_info)
|
128
|
+
appcontroller.should_receive(:get_userappserver_ip).and_return("127.0.0.1")
|
129
|
+
flexmock(AppControllerClient).should_receive(:new).and_return(appcontroller)
|
130
|
+
|
131
|
+
commonfunctions = flexmock(CommonFunctions)
|
132
|
+
commonfunctions.should_receive(:read_file).
|
133
|
+
with(File.expand_path("~/.appscale/locations-#{@keyname}.json")).
|
134
|
+
and_return(JSON.dump(@role_info))
|
135
|
+
commonfunctions.should_receive(:write_file).with(
|
136
|
+
File.expand_path("~/.appscale/locations-#{@keyname}.json"),
|
137
|
+
JSON.dump(@role_info)).and_return()
|
138
|
+
|
139
|
+
userappclient = flexmock(UserAppClient)
|
140
|
+
userappclient.new_instances { |instance|
|
141
|
+
instance.should_receive(:change_password).and_return("OK")
|
142
|
+
}
|
143
|
+
|
144
|
+
assert_nothing_raised(Exception) {
|
145
|
+
AppScaleTools.reset_password(@options)
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_usage_is_up_to_date
|
150
|
+
AppScaleTools::RESET_PASSWORD_FLAGS.each { |flag|
|
151
|
+
assert_equal(true,
|
152
|
+
AppScaleTools::RESET_PASSWORD_USAGE.include?("-#{flag}"),
|
153
|
+
"No usage text for #{flag}.")
|
154
|
+
}
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
2
|
+
require 'appscale_tools'
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
|
7
|
+
class TestAppScaleRunInstances < Test::Unit::TestCase
|
8
|
+
def setup
|
9
|
+
EC2_ENVIRONMENT_VARIABLES.each { |var|
|
10
|
+
ENV[var] = "BOO"
|
11
|
+
}
|
12
|
+
|
13
|
+
file = flexmock(File)
|
14
|
+
file.should_receive(:exists?).and_return(true)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_machine_not_set_in_cloud_deployments
|
18
|
+
options = {
|
19
|
+
"infrastructure" => "euca"
|
20
|
+
}
|
21
|
+
assert_raises(BadConfigurationException) {
|
22
|
+
AppScaleTools.run_instances(options)
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_environment_variables_not_set_in_cloud_deployments
|
27
|
+
options = {
|
28
|
+
"infrastructure" => "euca",
|
29
|
+
"machine" => "emi-ABCDEFG"
|
30
|
+
}
|
31
|
+
|
32
|
+
EC2_ENVIRONMENT_VARIABLES.each { |var|
|
33
|
+
ENV[var] = nil
|
34
|
+
}
|
35
|
+
|
36
|
+
assert_raises(BadConfigurationException) {
|
37
|
+
AppScaleTools.run_instances(options)
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_usage_is_up_to_date
|
42
|
+
AppScaleTools::RUN_INSTANCES_FLAGS.each { |flag|
|
43
|
+
assert_equal(true,
|
44
|
+
AppScaleTools::RUN_INSTANCES_USAGE.include?("-#{flag}"),
|
45
|
+
"No usage text for #{flag}.")
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|