Sha256: 537aaf2a2e023dd22e77438b539ee2889c573a668ab2dc9b5adb044f361c3c33

Contents?: true

Size: 2 KB

Versions: 2

Compression:

Stored size: 2 KB

Contents

require 'spec_helper'
require 'logger'
describe CephStorage::StorageObject::RadosStorageObjectEnumerator do
  let(:config) { cluster_config }
  let(:spconfig) { spec_config }
  let(:cluster) { CephStorage::ClusterFactory.build config }
  let(:rule_id) { spconfig[:pool][:rule_id] }
  let(:pool_name) { spconfig[:pool][:name] }
  let(:pool) { cluster.pool(pool_name) }

  describe 'pool creation' do
    subject { pool }
    it 'should be able to create pool' do
      expect { subject.create(rule_id: rule_id) }.to_not raise_exception
    end

    it 'should be writable' do
      expect { pool.stat }.not_to raise_exception
      expect(pool.stat).to be_a Hash
    end
  end

  let(:object_name) { spconfig[:pool][:object_name] }

  describe 'RadosStorageObjectEnumerator' do
    let(:storage_object_enumerator) { pool.storage_object_enumerator }
    subject { storage_object_enumerator }

    it 'should be a StorageObject::RadosObjectEnumerator' do
      expect(subject).to be_a(
        ::CephStorage::StorageObject::RadosStorageObjectEnumerator
      )
    end

    it 'should be a CephRuby::RadosObjectEnumerator' do
      expect(subject).to be_a ::CephRuby::RadosObjectEnumerator
    end

    describe 'before creation' do
      it 'should not throw have any objects in it' do
        expect(subject.inject(0) { |a, _e| a + 1 }).to be 0
      end
    end

    describe 'after populating' do
      before do
        10.times do |i|
          pool.storage_object("#{object_name}.#{i}").overwrite(
            'some important content'
          )
        end
      end

      it 'should have 10 objects in it' do
        expect(subject.inject(0) { |a, _e| a + 1 }).to be 10
      end

      it 'should return CephStorage::RadosStorageObject' do
        expect(subject.first).to be_a(
          CephStorage::StorageObject::RadosStorageObject
        )
      end
    end
  end

  describe 'pool deletion' do
    subject { pool }
    it 'should be able to delete pool' do
      expect { subject.destroy }.not_to raise_exception
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ceph_storage-0.1.1 spec/ceph_storage_rados_storage_object_enumerator_spec.rb
ceph_storage-0.1.0 spec/ceph_storage_rados_storage_object_enumerator_spec.rb