Sha256: ad799a1ffe195cd377009e01a6830c7d0c177fe40cc075211bc5765e76380b2f

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

require 'hodor/api/hdfs'

module Hodor

  describe Hdfs do

    describe "Required Public Interface" do

      # .instance instead of .new necessitated by singleton:
      subject(:hdfs_methods) { Hodor::Hdfs.instance_methods }

      # Public methods
      it { should include :pwd }
      it { should include :path_on_hdfs }

    end

    context "test local to hdfs path operations" do

      before(:each) do
        use_settings hdfs_root: "/", hdfs_user: "hdfs"
        use_pwd "company/workers/noop", false
      end

      context "ensure pwd maps correctly between file systems" do

        subject(:hdfs) { Hodor::Hdfs.instance }

        it "should correctly map test repo path to HDFS path" do
          expect(hdfs.pwd).to match(/\/company\/workers\/noop/)
        end
      end

      context "test putting file to HDFS" do

        subject(:env) { Hodor::Environment.instance }
        subject(:hdfs) { Hodor::Hdfs.instance }

        it "should successfully construct ssh commandline to put file to HDFS" do
          expect(File).to receive(:exists?).twice { true }
          expect(env).to receive(:run_local).with(/cat workflow.xml.*=hdfs\s.*-put - \/company\/workers\/noop\/workflow.xml/, anything)
          hdfs.put_file("workflow.xml")
        end
      end

      context "test putting directory to HDFS" do

        subject(:env) { Hodor::Environment.instance }
        subject(:hdfs) { Hodor::Hdfs.instance }

        it "should successfully construct ssh commandline to put directory to HDFS" do
          expect(File).to receive(:exists?).twice { true }
          expect(env).to receive(:run_local).with(/cat workflow.xml.*=hdfs\s.*-put - \/company\/workers\/noop\/workflow.xml/, anything)
          hdfs.put_file("workflow.xml")
        end
      end


    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hodor-1.0.2 spec/unit/hodor/api/hdfs_spec.rb