terminal.com 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +118 -29
- data/bin/terminal.com +12 -7
- data/lib/terminal.com.rb +998 -317
- data/lib/terminal.com/api.rb +202 -0
- data/spec/low-level/browse_snapshots_and_users_spec.rb +158 -0
- data/spec/low-level/create_and_manage_terminals_spec.rb +199 -0
- data/spec/low-level/terminal.com_spec.rb +31 -0
- data/spec/spec_helper.rb +79 -0
- metadata +9 -5
- data/spec/terminal.com_spec.rb +0 -0
@@ -0,0 +1,202 @@
|
|
1
|
+
require_relative '../terminal.com'
|
2
|
+
|
3
|
+
module Terminal
|
4
|
+
class API
|
5
|
+
# https://www.terminal.com/faq#instanceTypes
|
6
|
+
INSTANCE_TYPES = {
|
7
|
+
micro: {cpu: '2 (max)', ram: 256},
|
8
|
+
mini: {cpu: 50, ram: 800},
|
9
|
+
small: {cpu: 100, ram: 1600},
|
10
|
+
medium: {cpu: 200, ram: 3200},
|
11
|
+
xlarge: {cpu: 400, ram: 6400},
|
12
|
+
:'2xlarge' => {cpu: 800, ram: 12_800},
|
13
|
+
:'4xlarge' => {cpu: 1600, ram: 25_600},
|
14
|
+
:'8xlarge' => {cpu: 3200, ram: 51_200}
|
15
|
+
}
|
16
|
+
|
17
|
+
def initialize(user_token, access_token)
|
18
|
+
@user_token, @access_token = user_token, access_token
|
19
|
+
end
|
20
|
+
|
21
|
+
###############################
|
22
|
+
# CREATE AND MANAGE TERMINALS #
|
23
|
+
###############################
|
24
|
+
|
25
|
+
def list_terminals
|
26
|
+
Terminal::API.list_terminals(@user_token, @access_token)
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_terminal(**options)
|
30
|
+
Terminal::API.get_terminal(@user_token, @access_token, **options)
|
31
|
+
end
|
32
|
+
|
33
|
+
def start_snapshot(snapshot_id, **options)
|
34
|
+
if options[:instance]
|
35
|
+
unless instance_opts = INSTANCE_TYPES[options[:instance]]
|
36
|
+
raise ArgumentError.new("No such instance type: #{options[:instance].inspect}. Instance types are: #{INSTANCE_TYPES.keys.inspect[1..-2]}.")
|
37
|
+
end
|
38
|
+
|
39
|
+
options.delete(:instance)
|
40
|
+
options.merge!(instance_opts)
|
41
|
+
end
|
42
|
+
|
43
|
+
Terminal::API.start_snapshot(@user_token, @access_token, snapshot_id, **options)
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete_terminal(container_key)
|
47
|
+
Terminal::API.delete_terminal(@user_token, @access_token, container_key)
|
48
|
+
end
|
49
|
+
|
50
|
+
def restart_terminal(container_key)
|
51
|
+
Terminal::API.restart_terminal(@user_token, @access_token, container_key)
|
52
|
+
end
|
53
|
+
|
54
|
+
def pause_terminal(container_key)
|
55
|
+
Terminal::API.pause_terminal(@user_token, @access_token, container_key)
|
56
|
+
end
|
57
|
+
|
58
|
+
def resume_terminal(container_key)
|
59
|
+
Terminal::API.resume_terminal(@user_token, @access_token, container_key)
|
60
|
+
end
|
61
|
+
|
62
|
+
def edit_terminal(container_key, **options)
|
63
|
+
Terminal::API.edit_terminal(@user_token, @access_token, container_key, **options)
|
64
|
+
end
|
65
|
+
|
66
|
+
###############################
|
67
|
+
# CREATE AND MANAGE SNAPSHOTS #
|
68
|
+
###############################
|
69
|
+
|
70
|
+
def list_snapshots(**options)
|
71
|
+
Terminal::API.list_snapshots(@user_token, @access_token, **options)
|
72
|
+
end
|
73
|
+
|
74
|
+
def count_snapshots(**options)
|
75
|
+
Terminal::API.count_snapshots(@user_token, @access_token, **options)
|
76
|
+
end
|
77
|
+
|
78
|
+
def delete_snapshot(snapshot_id)
|
79
|
+
Terminal::API.delete_snapshot(@user_token, @access_token, snapshot_id)
|
80
|
+
end
|
81
|
+
|
82
|
+
def edit_snapshot(snapshot_id, **options)
|
83
|
+
Terminal::API.edit_snapshot(@user_token, @access_token, snapshot_id, **options)
|
84
|
+
end
|
85
|
+
|
86
|
+
def snapshot_terminal(container_key, **options)
|
87
|
+
Terminal::API.snapshot_terminal(@user_token, @access_token, container_key, **options)
|
88
|
+
end
|
89
|
+
|
90
|
+
##########################
|
91
|
+
# MANAGE TERMINAL ACCESS #
|
92
|
+
##########################
|
93
|
+
|
94
|
+
def add_terminal_links(container_key, *links)
|
95
|
+
Terminal::API.add_terminal_links(@user_token, @access_token, container_key, *links)
|
96
|
+
end
|
97
|
+
|
98
|
+
def remove_terminal_links(container_key, *links)
|
99
|
+
Terminal::API.remove_terminal_links(@user_token, @access_token, container_key, *links)
|
100
|
+
end
|
101
|
+
|
102
|
+
def list_terminal_access(container_key)
|
103
|
+
Terminal::API.list_terminal_access(@user_token, @access_token, container_key)
|
104
|
+
end
|
105
|
+
|
106
|
+
def edit_terminal_access(container_key, **options)
|
107
|
+
Terminal::API.edit_terminal_access(@user_token, @access_token, container_key, **options)
|
108
|
+
end
|
109
|
+
|
110
|
+
#################################
|
111
|
+
# MANAGE TERMINAL DNS & DOMAINS #
|
112
|
+
#################################
|
113
|
+
|
114
|
+
def get_cname_records
|
115
|
+
Terminal::API.get_cname_records(@user_token, @access_token)
|
116
|
+
end
|
117
|
+
|
118
|
+
def add_domain_to_pool
|
119
|
+
Terminal::API.add_domain_to_pool(@user_token, @access_token, domain)
|
120
|
+
end
|
121
|
+
|
122
|
+
def remove_domain_from_pool
|
123
|
+
Terminal::API.remove_domain_from_pool(@user_token, @access_token, domain)
|
124
|
+
end
|
125
|
+
|
126
|
+
def add_cname_record(domain, subdomain, port)
|
127
|
+
Terminal::API.add_cname_record(@user_token, @access_token, domain, subdomain, port)
|
128
|
+
end
|
129
|
+
|
130
|
+
def remove_cname_record(domain)
|
131
|
+
Terminal::API.remove_cname_record(@user_token, @access_token, domain)
|
132
|
+
end
|
133
|
+
|
134
|
+
#################################
|
135
|
+
# MANAGE TERMINAL IDLE SETTINGS #
|
136
|
+
#################################
|
137
|
+
|
138
|
+
def set_terminal_idle_settings(container_key, action, *triggers)
|
139
|
+
Terminal::API.set_terminal_idle_settings(@user_token, @access_token, action, *triggers)
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_terminal_idle_settings(container_key)
|
143
|
+
Terminal::API.get_terminal_idle_settings(@user_token, @access_token, container_key)
|
144
|
+
end
|
145
|
+
|
146
|
+
def balance
|
147
|
+
Terminal::API.balance(@user_token, @access_token)
|
148
|
+
end
|
149
|
+
|
150
|
+
def balance_added
|
151
|
+
Terminal::API.balance_added(@user_token, @access_token)
|
152
|
+
end
|
153
|
+
|
154
|
+
def gift(email, cents)
|
155
|
+
Terminal::API.gift(@user_token, @access_token, email, cents)
|
156
|
+
end
|
157
|
+
|
158
|
+
def burn_history
|
159
|
+
Terminal::API.burn_history(@user_token, @access_token)
|
160
|
+
end
|
161
|
+
|
162
|
+
def terminal_usage_history
|
163
|
+
Terminal::API.terminal_usage_history(@user_token, @access_token)
|
164
|
+
end
|
165
|
+
|
166
|
+
def burn_state
|
167
|
+
Terminal::API.burn_state(@user_token, @access_token)
|
168
|
+
end
|
169
|
+
|
170
|
+
def burn_estimates
|
171
|
+
Terminal::API.burn_estimates(@user_token, @access_token)
|
172
|
+
end
|
173
|
+
|
174
|
+
##########################
|
175
|
+
# MANAGE SSH PUBLIC KEYS #
|
176
|
+
##########################
|
177
|
+
|
178
|
+
def add_authorized_key_to_terminal(container_key, publicKey)
|
179
|
+
Terminal::API.add_authorized_key_to_terminal(@user_token, @access_token, container_key, publicKey)
|
180
|
+
end
|
181
|
+
|
182
|
+
def add_authorized_key_to_ssh_proxy(name, publicKey)
|
183
|
+
Terminal::API.add_authorized_key_to_ssh_proxy(@user_token, @access_token, name, publicKey)
|
184
|
+
end
|
185
|
+
|
186
|
+
def del_authorized_key_from_ssh_proxy(name, fingerprint)
|
187
|
+
Terminal::API.del_authorized_key_from_ssh_proxy(@user_token, @access_token, name, fingerprint)
|
188
|
+
end
|
189
|
+
|
190
|
+
def get_authorized_key_from_ssh_proxy
|
191
|
+
Terminal::API.get_authorized_key_from_ssh_proxy(@user_token, @access_token)
|
192
|
+
end
|
193
|
+
|
194
|
+
#########
|
195
|
+
# OTHER #
|
196
|
+
#########
|
197
|
+
|
198
|
+
def who_am_i
|
199
|
+
Terminal::API.who_am_i(@user_token, @access_token)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,158 @@
|
|
1
|
+
describe Terminal do
|
2
|
+
describe '.get_snapshot(snapshot_id)' do
|
3
|
+
it 'fetches info about the snapshot' do
|
4
|
+
response = VCR.use_cassette('get_snapshot') do
|
5
|
+
described_class.get_snapshot(ubuntu_snap_id)
|
6
|
+
end
|
7
|
+
|
8
|
+
expect(response['snapshot']['title']).to eq('Official Ubuntu 14.04')
|
9
|
+
expect(response['snapshot']['author']).to eq('terminal')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.get_profile(profile_id)' do
|
14
|
+
it 'fetches info about the profile' do
|
15
|
+
response = VCR.use_cassette('get_profile') do
|
16
|
+
described_class.get_profile('botanicus')
|
17
|
+
end
|
18
|
+
|
19
|
+
expect(response['user']['name']).to eq('James C Russell')
|
20
|
+
expect(response['user']['username']).to eq('botanicus')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '.list_public_snapshots(**options)' do
|
25
|
+
it 'fetches all the public snapshots by default' do
|
26
|
+
response = VCR.use_cassette('list_public_snapshots') do
|
27
|
+
described_class.list_public_snapshots
|
28
|
+
end
|
29
|
+
|
30
|
+
expect(response['snapshots'].length).to eq(460)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'fetches all the featured snapshots' do
|
34
|
+
response = VCR.use_cassette('list_public_snapshots_featured') do
|
35
|
+
described_class.list_public_snapshots(featured: true)
|
36
|
+
end
|
37
|
+
|
38
|
+
expect(response['snapshots'].map { |snap| snap['featured'] }).to all(be(true))
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'fetches all the snapshots by given username' do
|
42
|
+
response = VCR.use_cassette('list_public_snapshots_terminal') do
|
43
|
+
described_class.list_public_snapshots(username: 'terminal')
|
44
|
+
end
|
45
|
+
|
46
|
+
expect(response['snapshots'].map { |snap| snap['author'] }).to all(eq('terminal'))
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'fetches all the snapshots with given tag' do
|
50
|
+
response = VCR.use_cassette('list_public_snapshots_ubuntu') do
|
51
|
+
described_class.list_public_snapshots(tag: 'ubuntu')
|
52
|
+
end
|
53
|
+
|
54
|
+
expect(response['snapshots'].map { |snap| snap['tags'] }).to all(include('ubuntu'))
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'fetches all the snapshots with given title' do
|
58
|
+
response = VCR.use_cassette('list_public_snapshots_ubuntu_official') do
|
59
|
+
described_class.list_public_snapshots(title: 'Official Ubuntu 14.04')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Here's a slight caveat, this is not eql, but match. So the following are both valid:
|
63
|
+
# ["Official Ubuntu 14.04", "Haskell Platform on Official Ubuntu 14.04"]
|
64
|
+
expect(response['snapshots'].map { |snap| snap['title'] }).to all(match('Official Ubuntu 14.04'))
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'fetches all the featured snapshots sorted by popularity' do
|
68
|
+
response = VCR.use_cassette('list_public_snapshots_featured_sorted_by_popularity') do
|
69
|
+
described_class.list_public_snapshots(featured: true, sortby: 'popularity')
|
70
|
+
end
|
71
|
+
|
72
|
+
expect(response['snapshots'].map { |snap| snap['featured'] }).to all(be(true))
|
73
|
+
|
74
|
+
start_counts = response['snapshots'].map { |snap| snap['start_count'] }
|
75
|
+
expect(start_counts).to eq(start_counts.sort.reverse)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'fetches all the featured snapshots sorted by date' do
|
79
|
+
response = VCR.use_cassette('list_public_snapshots_featured_sorted_by_date') do
|
80
|
+
described_class.list_public_snapshots(featured: true, sortby: 'date')
|
81
|
+
end
|
82
|
+
|
83
|
+
expect(response['snapshots'].map { |snap| snap['featured'] }).to all(be(true))
|
84
|
+
|
85
|
+
created_at_dates = response['snapshots'].map { |snap| Date.parse(snap['createdAt']) }
|
86
|
+
expect(created_at_dates).to eq(created_at_dates.sort.reverse)
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'with pagination' do
|
90
|
+
it 'fetches first page of the public snapshots' do
|
91
|
+
response = VCR.use_cassette('list_public_snapshots_page_1') do
|
92
|
+
described_class.list_public_snapshots(page: 1, perPage: 1)
|
93
|
+
end
|
94
|
+
|
95
|
+
expect(response['snapshots'].length).to eq(1)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'fetches subsequent pages of the public snapshots' do
|
99
|
+
page_one = VCR.use_cassette('list_public_snapshots_page_1') do
|
100
|
+
described_class.list_public_snapshots(page: 1, perPage: 1)
|
101
|
+
end
|
102
|
+
|
103
|
+
page_two = VCR.use_cassette('list_public_snapshots_page_2') do
|
104
|
+
described_class.list_public_snapshots(page: 2, perPage: 1)
|
105
|
+
end
|
106
|
+
|
107
|
+
expect(page_one['snapshots'].length).to eq(1)
|
108
|
+
expect(page_two['snapshots'].length).to eq(1)
|
109
|
+
|
110
|
+
expect(page_one).not_to eql(page_two)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe '.count_public_snapshots(**options)' do
|
116
|
+
it 'fetches all the public snapshots by default' do
|
117
|
+
response = VCR.use_cassette('count_public_snapshots') do
|
118
|
+
described_class.count_public_snapshots
|
119
|
+
end
|
120
|
+
|
121
|
+
expect(response['snapshot_count']).to eq(460)
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'fetches all the featured snapshots' do
|
125
|
+
response = VCR.use_cassette('count_public_snapshots_featured') do
|
126
|
+
described_class.count_public_snapshots(featured: true)
|
127
|
+
end
|
128
|
+
|
129
|
+
expect(response['snapshot_count']).to eq(136)
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'fetches all the snapshots by given username' do
|
133
|
+
response = VCR.use_cassette('count_public_snapshots_terminal') do
|
134
|
+
described_class.count_public_snapshots(username: 'terminal')
|
135
|
+
end
|
136
|
+
|
137
|
+
expect(response['snapshot_count']).to eq(55)
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'fetches all the snapshots with given tag' do
|
141
|
+
response = VCR.use_cassette('count_public_snapshots_ubuntu') do
|
142
|
+
described_class.count_public_snapshots(tag: 'ubuntu')
|
143
|
+
end
|
144
|
+
|
145
|
+
expect(response['snapshot_count']).to eq(358)
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'fetches all the snapshots with given title' do
|
149
|
+
response = VCR.use_cassette('count_public_snapshots_ubuntu_official') do
|
150
|
+
described_class.count_public_snapshots(title: 'Official Ubuntu 14.04')
|
151
|
+
end
|
152
|
+
|
153
|
+
# Here's a slight caveat, this is not eql, but match. So the following are both valid:
|
154
|
+
# ["Official Ubuntu 14.04", "Haskell Platform on Official Ubuntu 14.04"]
|
155
|
+
expect(response['snapshot_count']).to eq(17)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,199 @@
|
|
1
|
+
describe Terminal do
|
2
|
+
describe '.list_terminals(user_token, access_token)' do
|
3
|
+
it 'lists all my Terminals' do
|
4
|
+
response = VCR.use_cassette('list_terminals') do
|
5
|
+
described_class.list_terminals(user_token, access_token)
|
6
|
+
end
|
7
|
+
|
8
|
+
expect(response['terminals'].length).to eq(2)
|
9
|
+
expect(response['terminals'][0]['name']).to eql('Coding Interview: John Doe Jr')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.get_terminal(user_token, access_token, **options)' do
|
14
|
+
context 'with given container_key' do
|
15
|
+
it 'retrieves info about given Terminal' do
|
16
|
+
response = VCR.use_cassette('get_terminal_with_container_key') do
|
17
|
+
container_key = 'b878c064-fc2b-4f14-81fa-ca10ac9385ff'
|
18
|
+
described_class.get_terminal(user_token, access_token, container_key: container_key)
|
19
|
+
end
|
20
|
+
|
21
|
+
expect(response['terminal']['name']).to eql('Coding Interview: John Doe Jr')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with given subdomain' do
|
26
|
+
it 'retrieves info about given Terminal' do
|
27
|
+
response = VCR.use_cassette('get_terminal_with_subdomain') do
|
28
|
+
described_class.get_terminal(user_token, access_token, subdomain: 'botanicus117')
|
29
|
+
end
|
30
|
+
|
31
|
+
expect(response['terminal']['name']).to eql('Coding Interview: John Doe Jr')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.start_snapshot(user_token, access_token, snapshot_id, **options)' do
|
37
|
+
it 'should start given snapshot' do
|
38
|
+
response = VCR.use_cassette('start_snapshot') do
|
39
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
40
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id)
|
41
|
+
end
|
42
|
+
|
43
|
+
response = VCR.use_cassette('start_snapshot_request_progress') do
|
44
|
+
described_class.request_progress(response['request_id'])
|
45
|
+
end
|
46
|
+
|
47
|
+
expect(response['status']).to eql('created')
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with either cpu or ram' do
|
51
|
+
it 'should raise an argument error if only cpu is provided' do
|
52
|
+
expect {
|
53
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
54
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, cpu: '2 (max)')
|
55
|
+
}.to raise_error(ArgumentError)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should raise an argument error if only ram is provided' do
|
59
|
+
expect {
|
60
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
61
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, ram: 256)
|
62
|
+
}.to raise_error(ArgumentError)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'with given cpu and ram' do
|
67
|
+
it 'should start given snapshot with cpu 2 (max) and ram 256' do
|
68
|
+
response = VCR.use_cassette('start_snapshot_valid_cpu_ram') do
|
69
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
70
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, cpu: '2 (max)', ram: 256)
|
71
|
+
end
|
72
|
+
|
73
|
+
sleep 16.5 unless File.exist?('spec/low-level/fixtures/start_snapshot_request_progress_valid_cpu_ram.yml')
|
74
|
+
|
75
|
+
response = VCR.use_cassette('start_snapshot_request_progress_valid_cpu_ram') do
|
76
|
+
described_class.request_progress(response['request_id'])
|
77
|
+
end
|
78
|
+
|
79
|
+
expect(response['result']['cpu']).to eql('2 (max)')
|
80
|
+
expect(response['result']['ram']).to eql(256)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should start given snapshot with cpu 200 and ram 3200' do
|
84
|
+
response = VCR.use_cassette('start_snapshot_valid_cpu_ram_2') do
|
85
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
86
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, cpu: 200, ram: 3200)
|
87
|
+
end
|
88
|
+
|
89
|
+
sleep 16.5 unless File.exist?('spec/low-level/fixtures/start_snapshot_request_progress_valid_cpu_ram_2.yml')
|
90
|
+
|
91
|
+
response = VCR.use_cassette('start_snapshot_request_progress_valid_cpu_ram_2') do
|
92
|
+
described_class.request_progress(response['request_id'])
|
93
|
+
end
|
94
|
+
|
95
|
+
expect(response['result']['cpu']).to eql(200)
|
96
|
+
expect(response['result']['ram']).to eql(3200)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context 'with given name' do
|
101
|
+
it 'should start given snapshot' do
|
102
|
+
response = VCR.use_cassette('start_snapshot_with_name') do
|
103
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
104
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, name: 'QA: User Listing #356')
|
105
|
+
end
|
106
|
+
|
107
|
+
sleep 16.5 unless File.exist?('spec/low-level/fixtures/start_snapshot_request_progress_with_name.yml')
|
108
|
+
|
109
|
+
response = VCR.use_cassette('start_snapshot_request_progress_with_name') do
|
110
|
+
described_class.request_progress(response['request_id'])
|
111
|
+
end
|
112
|
+
|
113
|
+
expect(response['result']['name']).to eql('QA: User Listing #356')
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'with autopause on' do
|
118
|
+
it 'should start given snapshot' do
|
119
|
+
response = VCR.use_cassette('start_snapshot_with_autopause_on') do
|
120
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
121
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, autopause: true)
|
122
|
+
end
|
123
|
+
|
124
|
+
sleep 16.5 unless File.exist?('spec/low-level/fixtures/start_snapshot_request_progress_with_autopause_on.yml')
|
125
|
+
|
126
|
+
response = VCR.use_cassette('start_snapshot_request_progress_with_autopause_on') do
|
127
|
+
described_class.request_progress(response['request_id'])
|
128
|
+
end
|
129
|
+
|
130
|
+
# Autopause isn't propagated to the result object.
|
131
|
+
# If this succeeded, we expect everything to be OK.
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'with autopause off' do
|
136
|
+
it 'should start given snapshot' do
|
137
|
+
response = VCR.use_cassette('start_snapshot_with_autopause_off') do
|
138
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
139
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, autopause: false)
|
140
|
+
end
|
141
|
+
|
142
|
+
sleep 16.5 unless File.exist?('spec/low-level/fixtures/start_snapshot_request_progress_with_autopause_off.yml')
|
143
|
+
|
144
|
+
response = VCR.use_cassette('start_snapshot_request_progress_with_autopause_off') do
|
145
|
+
described_class.request_progress(response['request_id'])
|
146
|
+
end
|
147
|
+
|
148
|
+
# Autopause isn't propagated to the result object.
|
149
|
+
# If this succeeded, we expect everything to be OK.
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
context 'with temporary on' do
|
154
|
+
it 'should start given snapshot' do
|
155
|
+
response = VCR.use_cassette('start_snapshot_with_temporary_on') do
|
156
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
157
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, temporary: true)
|
158
|
+
end
|
159
|
+
|
160
|
+
sleep 16.5 unless File.exist?('spec/low-level/fixtures/start_snapshot_request_progress_with_temporary_on.yml')
|
161
|
+
|
162
|
+
response = VCR.use_cassette('start_snapshot_request_progress_with_temporary_on') do
|
163
|
+
described_class.request_progress(response['request_id'])
|
164
|
+
end
|
165
|
+
|
166
|
+
# Temporary isn't propagated to the result object.
|
167
|
+
# If this succeeded, we expect everything to be OK.
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context 'with temporary off' do
|
172
|
+
it 'should start given snapshot' do
|
173
|
+
response = VCR.use_cassette('start_snapshot_with_temporary_off') do
|
174
|
+
snapshot_id = '57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234'
|
175
|
+
described_class.start_snapshot(user_token, access_token, snapshot_id, temporary: false)
|
176
|
+
end
|
177
|
+
|
178
|
+
sleep 16.5 unless File.exist?('spec/low-level/fixtures/start_snapshot_request_progress_with_temporary_off.yml')
|
179
|
+
|
180
|
+
response = VCR.use_cassette('start_snapshot_request_progress_with_temporary_off') do
|
181
|
+
described_class.request_progress(response['request_id'])
|
182
|
+
end
|
183
|
+
|
184
|
+
# Temporary isn't propagated to the result object.
|
185
|
+
# If this succeeded, we expect everything to be OK.
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
# :temporary, :startup_script, :custom_data)
|
190
|
+
#
|
191
|
+
# "result"=>{"cpu"=>"2 (max)", "ram"=>256, "diskspace"=>10,
|
192
|
+
# "name"=>"Ubuntu 14.04 Base Dev Snapshot",
|
193
|
+
# "snapshot_id"=>"57eff3574ac8d438224dc3aa1c6431a0dbac849a0c254e89be2e758d8113c234",
|
194
|
+
# "status"=>"running", "allow_spot"=>false,
|
195
|
+
# "container_key"=>"d6e9e1ee-d334-4027-b365-5d7eebe5a1d7",
|
196
|
+
# "subdomain"=>"botanicus221", "container_ip"=>"240.3.42.64",
|
197
|
+
# "creation_time"=>1417452412482}}
|
198
|
+
end
|
199
|
+
end
|