Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Test] Testing with different architecture #282

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
27 changes: 27 additions & 0 deletions .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ARG ELASTIC_STACK_VERSION
ARG DISTRIBUTION_SUFFIX
FROM docker.elastic.co/logstash/logstash${DISTRIBUTION_SUFFIX}:${ELASTIC_STACK_VERSION}
USER root
RUN localedef -i en_US -f UTF-8 en_US.UTF-8
RUN locale -a
USER logstash

COPY --chown=logstash:logstash Gemfile /usr/share/plugins/plugin/Gemfile
COPY --chown=logstash:logstash *.gemspec VERSION* version* /usr/share/plugins/plugin/
RUN cp /usr/share/logstash/logstash-core/versions-gem-copy.yml /usr/share/logstash/versions.yml
# NOTE: since 8.0 JDK is bundled as part of the LS distribution under $LS_HOME/jdk
ENV PATH="${PATH}:/usr/share/logstash/vendor/jruby/bin:/usr/share/logstash/jdk/bin"
ENV LOGSTASH_SOURCE="1"
ENV ELASTIC_STACK_VERSION=$ELASTIC_STACK_VERSION
# DISTRIBUTION="default" (by default) or "oss"
ARG DISTRIBUTION
ENV DISTRIBUTION=$DISTRIBUTION
# INTEGRATION="true" while integration testing (false-y by default)
ARG INTEGRATION
ENV INTEGRATION=$INTEGRATION
RUN gem install bundler -v '< 2'
WORKDIR /usr/share/plugins/plugin
RUN bundle install --with test ci
COPY --chown=logstash:logstash . /usr/share/plugins/plugin
RUN bundle exec rake vendor
RUN .ci/setup.sh
19 changes: 18 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
import:
- logstash-plugins/.ci:travis/[email protected]
- logstash-plugins/.ci:travis/[email protected]

before_install:
- sudo apt-get install jq
- sudo apt-get install libseccomp-dev
- sudo locale-gen en_US.UTF-8
- sudo dpkg-reconfigure locales
arch:
- arm64
- amd64

virt: vm

env:
jobs:
- ELASTIC_STACK_VERSION=7.x
- SNAPSHOT=true ELASTIC_STACK_VERSION=8.0.0-SNAPSHOT
- SNAPSHOT=true ELASTIC_STACK_VERSION=7.11.0-SNAPSHOT
11 changes: 9 additions & 2 deletions lib/filewatch/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# https://raw.githubusercontent.com/rails/rails/v4.2.1/activesupport/lib/active_support/core_ext/file/atomic.rb
# change method name to avoid borking active_support and vice versa
require 'fileutils'
require "logstash/util/loggable"

module FileHelper
include LogStash::Util::Loggable
extend self
# Write to a file atomically. Useful for situations where you don't
# want other processes or threads to see half-written files.
Expand Down Expand Up @@ -38,8 +40,13 @@ def write_atomically(file_name)
return return_val if old_stat.nil?

# Set correct uid/gid on new file
File.chown(old_stat.uid, old_stat.gid, file_name) if old_stat

if old_stat
begin
File.chown(old_stat.uid, old_stat.gid, file_name)
rescue Errno::EPERM => e
logger.error("sincedb_write: #{file_name} error:", :old_stat => old_stat, :exception => e.class, :message => e.message)
end
end
return_val
end

Expand Down
3 changes: 2 additions & 1 deletion spec/inputs/file_read_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,11 @@
sincedb_content = File.read(sincedb_path).strip
expect( sincedb_content ).to_not be_empty

Stud.try(3.times) do
Stud.try(10.times, RSpec::Expectations::ExpectationNotMetError) do
sleep(1.5) # > sincedb_clean_after

sincedb_content = File.read(sincedb_path).strip
puts "sincedb content is #{sincedb_content}"
expect( sincedb_content ).to be_empty
end
end
Expand Down
9 changes: 6 additions & 3 deletions spec/inputs/file_tail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,10 @@
let(:conf) { Hash.new }
let(:mlconf) { Hash.new }
let(:events) { Array.new }
let(:mlcodec) { LogStash::Codecs::Multiline.new(mlconf) }
let(:mlcodec) {
puts " The value of mlconf is #{mlconf}"
LogStash::Codecs::Multiline.new(mlconf)
}
let(:tracer_codec) { FileInput::CodecTracer.new }
let(:tmpdir_path) { Stud::Temporary.directory }
let(:tmpfile_path) { ::File.join(tmpdir_path, "#{suffix}.txt") }
Expand All @@ -222,7 +225,7 @@
fd.puts("ignore me 2")
fd.fsync
end
mlconf.update("pattern" => "^\s", "what" => "previous")
mlconf.update("pattern" => "^\\s", "what" => "previous")
conf.update("type" => "blah",
"path" => path_path,
"sincedb_path" => sincedb_path,
Expand Down Expand Up @@ -341,7 +344,7 @@
let(:suffix) { "J" }
let(:tmpfile_path2) { ::File.join(tmpdir_path, "K.txt") }
before do
mlconf.update("pattern" => "^\s", "what" => "previous")
mlconf.update("pattern" => "^\\s", "what" => "previous")
conf.update(
"type" => "blah",
"path" => path_path,
Expand Down