From 61f57d55b52974a9b17ea5a5578704a867babd87 Mon Sep 17 00:00:00 2001 From: Rick Bradley Date: Thu, 26 May 2016 15:42:54 -0500 Subject: [PATCH] (QENG-3919) Turns out, spush isn't a redis command And hence we see once again the weakness of mockist tests. --- lib/vmpooler/api/v1.rb | 2 +- spec/vmpooler/api/v1_spec.rb | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/vmpooler/api/v1.rb b/lib/vmpooler/api/v1.rb index 22aba6d..e095d0f 100644 --- a/lib/vmpooler/api/v1.rb +++ b/lib/vmpooler/api/v1.rb @@ -50,7 +50,7 @@ module Vmpooler end def return_single_vm(template, vm) - backend.spush('vmpooler__ready__' + template, vm) + backend.sadd('vmpooler__ready__' + template, vm) end def account_for_starting_vm(template, vm) diff --git a/spec/vmpooler/api/v1_spec.rb b/spec/vmpooler/api/v1_spec.rb index 8742974..af07883 100644 --- a/spec/vmpooler/api/v1_spec.rb +++ b/spec/vmpooler/api/v1_spec.rb @@ -304,7 +304,7 @@ describe Vmpooler::API::V1 do it 'fails when not all requested vms can be allocated' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - allow(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + allow(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm", '{"pool1":"1","pool2":"1"}' @@ -317,7 +317,7 @@ describe Vmpooler::API::V1 do it 'returns any checked out vms to their pools when not all requested vms can be allocated' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - expect(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + expect(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm", '{"pool1":"1","pool2":"1"}' @@ -330,7 +330,7 @@ describe Vmpooler::API::V1 do it 'fails when not all requested vms can be allocated, when requesting multiple instances from a pool' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - allow(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + allow(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm", '{"pool1":"2","pool2":"1"}' @@ -343,7 +343,7 @@ describe Vmpooler::API::V1 do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from a pool' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - expect(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times + expect(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times post "#{prefix}/vm", '{"pool1":"2","pool2":"1"}' @@ -356,7 +356,7 @@ describe Vmpooler::API::V1 do it 'fails when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - allow(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + allow(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm", '{"pool1":"2","pool2":"3"}' @@ -369,7 +369,7 @@ describe Vmpooler::API::V1 do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - expect(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times + expect(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times post "#{prefix}/vm", '{"pool1":"2","pool2":"3"}' @@ -570,7 +570,7 @@ describe Vmpooler::API::V1 do it 'fails when not all requested vms can be allocated' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - allow(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + allow(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm/pool1+pool2", '' @@ -583,7 +583,7 @@ describe Vmpooler::API::V1 do it 'returns any checked out vms to their pools when not all requested vms can be allocated' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - expect(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + expect(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm/pool1+pool2", '' @@ -596,7 +596,7 @@ describe Vmpooler::API::V1 do it 'fails when not all requested vms can be allocated, when requesting multiple instances from a pool' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - allow(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + allow(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm/pool1+pool1+pool2", '' @@ -609,7 +609,7 @@ describe Vmpooler::API::V1 do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from a pool' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - expect(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times + expect(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times post "#{prefix}/vm/pool1+pool1+pool2", '' @@ -622,7 +622,7 @@ describe Vmpooler::API::V1 do it 'fails when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - allow(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop") + allow(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop") post "#{prefix}/vm/pool1+pool1+pool2+pool2+pool2", '' @@ -635,7 +635,7 @@ describe Vmpooler::API::V1 do it 'returns any checked out vms to their pools when not all requested vms can be allocated, when requesting multiple instances from multiple pools' do allow(redis).to receive(:spop).with('vmpooler__ready__pool1').and_return 'abcdefghijklmnop' allow(redis).to receive(:spop).with('vmpooler__ready__pool2').and_return nil - expect(redis).to receive(:spush).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times + expect(redis).to receive(:sadd).with("vmpooler__ready__pool1", "abcdefghijklmnop").exactly(2).times post "#{prefix}/vm/pool1+pool1+pool2+pool2+pool2", ''