Sha256: 865730b603e030bf784ecd1407678af0df5e240912d1440b1620885e87f3839d

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

# encoding: utf-8

require 'logstash/devutils/rspec/spec_helper'
require 'logstash/logging/logger'
require 'logstash/outputs/oss'
require 'stud/temporary'
java_import 'com.aliyun.oss.model.GetObjectRequest'

# This file contains the common logic used by integration tests
shared_context "plugin initialize" do
  let(:endpoint) { ENV['OSS_ENDPOINT'] }
  let(:bucket) { ENV['OSS_BUCKET'] }
  let(:access_key_id) { ENV['OSS_ACCESS_KEY'] }
  let(:access_key_secret) { ENV['OSS_SECRET_KEY'] }
  let(:prefix) { "logstash" }
  let(:temporary_directory) { Stud::Temporary.pathname }

  let(:common_configurations) do
    {
      "endpoint" => endpoint,
      "bucket" => bucket,
      "access_key_id" => access_key_id,
      "access_key_secret" => access_key_secret,
      "prefix" => prefix,
      "size_rotate" => 1024,
      "time_rotate" => 60,
      "temporary_directory" => temporary_directory,
    }
  end

  LogStash::Logging::Logger::configure_logging("debug") if ENV["DEBUG"]

  let(:oss) { OSSClientBuilder.new().build(endpoint, access_key_id, access_key_secret) }
  subject { LogStash::Outputs::OSS.new(configurations) }
end

# remove object with `prefix`
def clean_bucket
  oss.listObjects(bucket, prefix).getObjectSummaries().each do |objectSummary|
    oss.deleteObject(bucket, objectSummary.getKey())
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-output-oss-0.1.2-java spec/integration/common.rb
logstash-output-oss-0.1.1-java spec/integration/common.rb