|
9 | 9 | before :each do
|
10 | 10 | end
|
11 | 11 |
|
| 12 | + describe '#list' do |
| 13 | + it 'skips empty platforms and lists aws' do |
| 14 | + stub_request(:get, "http://foo/status/platforms/vmpooler"). |
| 15 | + to_return(:status => 200, :body => "", :headers => {}) |
| 16 | + stub_request(:get, "http://foo/status/platforms/ondemand_vmpooler"). |
| 17 | + to_return(:status => 200, :body => "", :headers => {}) |
| 18 | + stub_request(:get, "http://foo/status/platforms/nspooler"). |
| 19 | + to_return(:status => 200, :body => "", :headers => {}) |
| 20 | + body = '{ |
| 21 | + "aws_platforms": [ |
| 22 | + "amazon-6-x86_64", |
| 23 | + "amazon-7-x86_64", |
| 24 | + "amazon-7-arm64", |
| 25 | + "centos-7-x86-64-west", |
| 26 | + "redhat-8-arm64" |
| 27 | + ] |
| 28 | + }' |
| 29 | + stub_request(:get, "http://foo/status/platforms/aws"). |
| 30 | + to_return(:status => 200, :body => body, :headers => {}) |
| 31 | + |
| 32 | + |
| 33 | + results = ABS.list(false, "http://foo") |
| 34 | + |
| 35 | + expect(results).to include("amazon-6-x86_64", "amazon-7-x86_64", "amazon-7-arm64", "centos-7-x86-64-west", "redhat-8-arm64") |
| 36 | + end |
| 37 | + it 'legacy JSON string, prior to PR 306' do |
| 38 | + stub_request(:get, "http://foo/status/platforms/vmpooler"). |
| 39 | + to_return(:status => 200, :body => "", :headers => {}) |
| 40 | + stub_request(:get, "http://foo/status/platforms/ondemand_vmpooler"). |
| 41 | + to_return(:status => 200, :body => "", :headers => {}) |
| 42 | + stub_request(:get, "http://foo/status/platforms/nspooler"). |
| 43 | + to_return(:status => 200, :body => "", :headers => {}) |
| 44 | + body = '{ |
| 45 | + "aws_platforms": "[\"amazon-6-x86_64\",\"amazon-7-x86_64\",\"amazon-7-arm64\",\"centos-7-x86-64-west\",\"redhat-8-arm64\"]" |
| 46 | + }' |
| 47 | + stub_request(:get, "http://foo/status/platforms/aws"). |
| 48 | + to_return(:status => 200, :body => body, :headers => {}) |
| 49 | + |
| 50 | + results = ABS.list(false, "http://foo") |
| 51 | + |
| 52 | + expect(results).to include("amazon-6-x86_64", "amazon-7-x86_64", "amazon-7-arm64", "centos-7-x86-64-west", "redhat-8-arm64") |
| 53 | + end |
| 54 | + end |
| 55 | + |
12 | 56 | describe '#format' do
|
13 | 57 | it 'returns an hash formatted like a vmpooler return, plus the job_id' do
|
14 | 58 | job_id = "generated_by_floaty_12345"
|
|
71 | 115 | # rubocop:disable Layout/LineLength
|
72 | 116 | @active_requests_response = '
|
73 | 117 | [
|
74 |
| - "{ \"state\":\"allocated\",\"last_processed\":\"2019-12-16 23:00:34 +0000\",\"allocated_resources\":[{\"hostname\":\"take-this.delivery.puppetlabs.net\",\"type\":\"win-2012r2-x86_64\",\"engine\":\"vmpooler\"}],\"audit_log\":{\"2019-12-13 16:45:29 +0000\":\"Allocated take-this.delivery.puppetlabs.net for job 1576255517241\"},\"request\":{\"resources\":{\"win-2012r2-x86_64\":1},\"job\":{\"id\":\"1576255517241\",\"tags\":{\"user\":\"test-user\"},\"user\":\"test-user\",\"time-received\":1576255519},\"priority\":1}}", |
| 118 | + { "state":"allocated","last_processed":"2019-12-16 23:00:34 +0000","allocated_resources":[{"hostname":"take-this.delivery.puppetlabs.net","type":"win-2012r2-x86_64","engine":"vmpooler"}],"audit_log":{"2019-12-13 16:45:29 +0000":"Allocated take-this.delivery.puppetlabs.net for job 1576255517241"},"request":{"resources":{"win-2012r2-x86_64":1},"job":{"id":"1576255517241","tags":{"user":"test-user"},"user":"test-user","time-received":1576255519},"priority":1}}, |
75 | 119 | "null",
|
76 |
| - "{\"state\":\"allocated\",\"last_processed\":\"2019-12-16 23:00:34 +0000\",\"allocated_resources\":[{\"hostname\":\"not-this.delivery.puppetlabs.net\",\"type\":\"win-2012r2-x86_64\",\"engine\":\"vmpooler\"}],\"audit_log\":{\"2019-12-13 16:46:14 +0000\":\"Allocated not-this.delivery.puppetlabs.net for job 1576255565159\"},\"request\":{\"resources\":{\"win-2012r2-x86_64\":1},\"job\":{\"id\":\"1576255565159\",\"tags\":{\"user\":\"not-test-user\"},\"user\":\"not-test-user\",\"time-received\":1576255566},\"priority\":1}}" |
| 120 | + {"state":"allocated","last_processed":"2019-12-16 23:00:34 +0000","allocated_resources":[{"hostname":"not-this.delivery.puppetlabs.net","type":"win-2012r2-x86_64","engine":"vmpooler"}],"audit_log":{"2019-12-13 16:46:14 +0000":"Allocated not-this.delivery.puppetlabs.net for job 1576255565159"},"request":{"resources":{"win-2012r2-x86_64":1},"job":{"id":"1576255565159","tags":{"user":"not-test-user"},"user":"not-test-user","time-received":1576255566},"priority":1}} |
77 | 121 | ]'
|
78 | 122 | # rubocop:enable Layout/LineLength
|
79 | 123 | @token = 'utpg2i2xswor6h8ttjhu3d47z53yy47y'
|
|
101 | 145 | # rubocop:disable Layout/LineLength
|
102 | 146 | @active_requests_response = '
|
103 | 147 | [
|
104 |
| - "{ \"state\":\"allocated\", \"last_processed\":\"2020-01-17 22:29:13 +0000\", \"allocated_resources\":[{\"hostname\":\"craggy-chord.delivery.puppetlabs.net\", \"type\":\"centos-7-x86_64\", \"engine\":\"vmpooler\"}, {\"hostname\":\"visible-revival.delivery.puppetlabs.net\", \"type\":\"centos-7-x86_64\", \"engine\":\"vmpooler\"}], \"audit_log\":{\"2020-01-17 22:28:45 +0000\":\"Allocated craggy-chord.delivery.puppetlabs.net, visible-revival.delivery.puppetlabs.net for job 1579300120799\"}, \"request\":{\"resources\":{\"centos-7-x86_64\":2}, \"job\":{\"id\":\"1579300120799\", \"tags\":{\"user\":\"test-user\"}, \"user\":\"test-user\", \"time-received\":1579300120}, \"priority\":3}}" |
| 148 | + { "state":"allocated", "last_processed":"2020-01-17 22:29:13 +0000", "allocated_resources":[{"hostname":"craggy-chord.delivery.puppetlabs.net", "type":"centos-7-x86_64", "engine":"vmpooler"}, {"hostname":"visible-revival.delivery.puppetlabs.net", "type":"centos-7-x86_64", "engine":"vmpooler"}], "audit_log":{"2020-01-17 22:28:45 +0000":"Allocated craggy-chord.delivery.puppetlabs.net, visible-revival.delivery.puppetlabs.net for job 1579300120799"}, "request":{"resources":{"centos-7-x86_64":2}, "job":{"id":"1579300120799", "tags":{"user":"test-user"}, "user":"test-user", "time-received":1579300120}, "priority":3}} |
105 | 149 | ]'
|
106 | 150 | @return_request = { '{"job_id":"1579300120799","hosts":{"hostname":"craggy-chord.delivery.puppetlabs.net","type":"centos-7-x86_64","engine":"vmpooler"},{"hostname":"visible-revival.delivery.puppetlabs.net","type":"centos-7-x86_64","engine":"vmpooler"}}'=>true }
|
107 | 151 | # rubocop:enable Layout/LineLength
|
|
0 commit comments