mirror of
https://github.com/elastic/logstash.git
synced 2025-04-19 04:15:23 -04:00
parent
0002dbc39f
commit
8ebde04ae8
22 changed files with 105 additions and 27 deletions
14
build.gradle
14
build.gradle
|
@ -385,10 +385,14 @@ if (!oss) {
|
|||
commandLine(['../bin/rspec', '-fd', 'qa/integration'])
|
||||
}
|
||||
|
||||
task runXPackUnitTests(type: Exec, dependsOn: installTestGems) {
|
||||
workingDir "${projectDir}/x-pack"
|
||||
standardOutput = new ExecLogOutputStream(System.out)
|
||||
errorOutput = new ExecLogOutputStream(System.err)
|
||||
commandLine(['../bin/rspec', 'spec', '-fd'])
|
||||
task runXPackUnitTests(dependsOn: [tasks.getByPath(":logstash-xpack:rubyTests")]) {}
|
||||
|
||||
project(":logstash-xpack") {
|
||||
["rubyTests", "test"].each { tsk ->
|
||||
tasks.getByPath(":logstash-xpack:" + tsk).configure {
|
||||
dependsOn bootstrap
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ module LogStash module Plugins
|
|||
# We need a threadsafe class here because we may perform
|
||||
# get/set operations concurrently despite the fact we don't use
|
||||
# the special atomic methods. That may not be apparent from this file,
|
||||
# but it is the case that we can call lookups from multiple threads,
|
||||
# but it is the case that we can call lookups from multiple threads,
|
||||
# when multiple pipelines are in play, and that a lookup may modify the registry.
|
||||
@registry = java.util.concurrent.ConcurrentHashMap.new
|
||||
@hooks = HooksRegistry.new
|
||||
|
@ -125,7 +125,7 @@ module LogStash module Plugins
|
|||
|
||||
def load_xpack
|
||||
logger.info("Loading x-pack")
|
||||
require_relative(::File.join(LogStash::ROOT, "x-pack/lib/logstash_registry"))
|
||||
require("x-pack/logstash_registry")
|
||||
end
|
||||
|
||||
def load_available_plugins
|
||||
|
|
|
@ -9,7 +9,10 @@ LogStash::XPACK_PATH = File.join(LogStash::ROOT, "x-pack")
|
|||
LogStash::OSS = ENV["OSS"] == "true" || !File.exists?(LogStash::XPACK_PATH)
|
||||
|
||||
if !LogStash::OSS
|
||||
$LOAD_PATH << File.join(LogStash::XPACK_PATH, "lib")
|
||||
xpack_dir = File.join(LogStash::XPACK_PATH, "lib")
|
||||
unless $LOAD_PATH.include?(xpack_dir)
|
||||
$LOAD_PATH.unshift(xpack_dir)
|
||||
end
|
||||
end
|
||||
|
||||
require "clamp"
|
||||
|
@ -206,6 +209,7 @@ class LogStash::Runner < Clamp::StrictCommand
|
|||
|
||||
# We configure the registry and load any plugin that can register hooks
|
||||
# with logstash, this needs to be done before any operation.
|
||||
SYSTEM_SETTINGS = LogStash::SETTINGS.clone
|
||||
LogStash::PLUGIN_REGISTRY.setup!
|
||||
|
||||
attr_reader :agent, :settings, :source_loader
|
||||
|
|
|
@ -5,3 +5,10 @@ project(':logstash-integration-tests').projectDir = new File('./qa/integration')
|
|||
project(':ingest-converter').projectDir = new File('./tools/ingest-converter')
|
||||
project(':benchmark-cli').projectDir = new File('./tools/benchmark-cli')
|
||||
project(':dependencies-report').projectDir = new File('./tools/dependencies-report')
|
||||
|
||||
Boolean oss = System.getenv('OSS').equals('true')
|
||||
|
||||
if (!oss) {
|
||||
include ':logstash-xpack'
|
||||
project(':logstash-xpack').projectDir = new File('./x-pack')
|
||||
}
|
||||
|
|
29
x-pack/build.gradle
Normal file
29
x-pack/build.gradle
Normal file
|
@ -0,0 +1,29 @@
|
|||
description = """Logstash X-Pack"""
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile project(':logstash-core')
|
||||
testCompile 'org.assertj:assertj-core:3.8.0'
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
test {
|
||||
exclude '/**'
|
||||
}
|
||||
|
||||
task rubyTests(type: Test) {
|
||||
inputs.files fileTree("${projectDir}/spec")
|
||||
inputs.files fileTree("${projectDir}/lib")
|
||||
inputs.files fileTree("${projectDir}/modules")
|
||||
systemProperty 'logstash.core.root.dir', projectDir.absolutePath
|
||||
include '/org/logstash/xpack/test/RSpecTests.class'
|
||||
}
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
require "logstash/bootstrap_check/default_config"
|
||||
|
||||
java_import java.util.concurrent.TimeUnit
|
||||
|
||||
module LogStash
|
||||
module ConfigManagement
|
||||
# Override the default Logstash's bootstrap check
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
require "logstash/environment"
|
||||
require "logstash/universal_plugin"
|
||||
require "logstash/runner"
|
||||
require "config_management/hooks"
|
||||
require "config_management/elasticsearch_source"
|
||||
require "config_management/bootstrap_check"
|
||||
|
@ -15,10 +14,12 @@ module LogStash
|
|||
include LogStash::Util::Loggable
|
||||
|
||||
def register_hooks(hooks)
|
||||
require "logstash/runner"
|
||||
hooks.register_hooks(LogStash::Runner, Hooks.new)
|
||||
end
|
||||
|
||||
def additionals_settings(settings)
|
||||
require "logstash/runner"
|
||||
logger.trace("Registering additionals settings")
|
||||
|
||||
settings.register(LogStash::Setting::Boolean.new("xpack.management.enabled", false))
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
# or more contributor license agreements. Licensed under the Elastic License;
|
||||
# you may not use this file except in compliance with the Elastic License.
|
||||
|
||||
require "logstash/runner"
|
||||
require "config_management/bootstrap_check"
|
||||
require "config_management/elasticsearch_source"
|
||||
require "logstash/config/source_loader"
|
||||
|
@ -18,6 +17,7 @@ module LogStash
|
|||
|
||||
def before_bootstrap_checks(runner)
|
||||
if management?(runner)
|
||||
require "logstash/runner"
|
||||
bootstrap_checks = LogStash::Runner::DEFAULT_BOOTSTRAP_CHECKS.dup
|
||||
|
||||
# We only need to allow logstash to start without any parameters
|
||||
|
|
|
@ -187,7 +187,7 @@ module LogStash
|
|||
settings.register(LogStash::Setting::String.new("node.uuid", ""))
|
||||
rescue => e
|
||||
logger.error e.message
|
||||
logger.error e.backtrace
|
||||
logger.error e.backtrace.to_s
|
||||
raise e
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,4 +16,4 @@ LogStash::PLUGIN_REGISTRY.add(:modules, "arcsight",
|
|||
LogStash::Modules::XpackScaffold.new("arcsight",
|
||||
File.join(File.dirname(__FILE__), "..", "modules", "arcsight", "configuration"),
|
||||
["basic", "trial", "standard", "gold", "platinum"]
|
||||
))
|
||||
))
|
1
x-pack/settings.gradle
Normal file
1
x-pack/settings.gradle
Normal file
|
@ -0,0 +1 @@
|
|||
rootProject.name = 'x-pack'
|
|
@ -11,7 +11,7 @@ require "config_management/bootstrap_check"
|
|||
describe LogStash::ConfigManagement::BootstrapCheck do
|
||||
let(:extension) { LogStash::ConfigManagement::Extension.new }
|
||||
|
||||
let(:system_settings) { LogStash::SETTINGS.clone }
|
||||
let(:system_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone }
|
||||
|
||||
subject { described_class }
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ describe LogStash::ConfigManagement::ElasticsearchSource do
|
|||
let(:elasticsearch_username) { "elastictest" }
|
||||
let(:elasticsearch_password) { "testchangeme" }
|
||||
let(:extension) { LogStash::ConfigManagement::Extension.new }
|
||||
let(:system_settings) { LogStash::SETTINGS.clone }
|
||||
let(:system_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone }
|
||||
let(:mock_license_client) { double("http_client") }
|
||||
let(:license_status) { 'active'}
|
||||
let(:license_type) { 'trial' }
|
||||
|
|
|
@ -23,7 +23,7 @@ describe LogStash::ConfigManagement::Extension do
|
|||
end
|
||||
|
||||
describe "#additionals_settings" do
|
||||
subject(:settings) { LogStash::SETTINGS.clone }
|
||||
subject(:settings) { LogStash::Runner::SYSTEM_SETTINGS.clone }
|
||||
|
||||
before { extension.additionals_settings(settings) }
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ describe LogStash::ConfigManagement::Hooks do
|
|||
end
|
||||
|
||||
before do
|
||||
system_settings = LogStash::SETTINGS.clone
|
||||
system_settings = LogStash::Runner::SYSTEM_SETTINGS.clone
|
||||
stub_const("LogStash::SETTINGS", system_settings)
|
||||
extension = LogStash::ConfigManagement::Extension.new
|
||||
extension.additionals_settings(system_settings)
|
||||
|
|
|
@ -90,7 +90,7 @@ describe LogStash::Helpers::ElasticsearchOptions do
|
|||
let(:expected_username) { elasticsearch_username }
|
||||
let(:expected_password) { elasticsearch_password }
|
||||
let(:extension) { LogStash::MonitoringExtension.new }
|
||||
let(:system_settings) { LogStash::SETTINGS.clone }
|
||||
let(:system_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone }
|
||||
|
||||
before :each do
|
||||
extension.additionals_settings(system_settings)
|
||||
|
@ -234,4 +234,4 @@ describe LogStash::Helpers::ElasticsearchOptions do
|
|||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ describe LogStash::LicenseChecker::XPackInfo do
|
|||
let(:issuer) { "elasticsearch"}
|
||||
let(:start_date_in_millis) { -1 }
|
||||
let(:extension) { LogStash::MonitoringExtension.new }
|
||||
let(:system_settings) { LogStash::SETTINGS.clone }
|
||||
let(:system_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone }
|
||||
let(:elasticsearch_url) { ["https://localhost:9898"] }
|
||||
let(:elasticsearch_username) { "elastictest" }
|
||||
let(:elasticsearch_password) { "testchangeme" }
|
||||
|
|
|
@ -31,7 +31,7 @@ describe LogStash::LicenseChecker::LicenseManager do
|
|||
let(:issuer) { "elasticsearch"}
|
||||
let(:start_date_in_millis) { -1 }
|
||||
let(:extension) { LogStash::MonitoringExtension.new }
|
||||
let(:system_settings) { LogStash::SETTINGS.clone }
|
||||
let(:system_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone }
|
||||
let(:elasticsearch_url) { ["https://localhost:9898"] }
|
||||
let(:elasticsearch_username) { "elastictest" }
|
||||
let(:elasticsearch_password) { "testchangeme" }
|
||||
|
|
|
@ -16,7 +16,7 @@ describe LogStash::LicenseChecker::LicenseReader do
|
|||
let(:elasticsearch_password) { "testchangeme" }
|
||||
let(:extension) { LogStash::MonitoringExtension.new }
|
||||
let(:system_settings) do
|
||||
LogStash::SETTINGS.clone.tap do |system_settings|
|
||||
LogStash::Runner::SYSTEM_SETTINGS.clone.tap do |system_settings|
|
||||
extension.additionals_settings(system_settings) # register defaults from extension
|
||||
apply_settings(settings, system_settings) # apply `settings`
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ require "logstash/modules/settings_merger"
|
|||
describe LogStash::LicenseChecker::ModuleLicenseChecker do
|
||||
|
||||
|
||||
let(:settings) {LogStash::SETTINGS.clone}
|
||||
let(:settings) { LogStash::Runner::SYSTEM_SETTINGS }
|
||||
|
||||
|
||||
shared_examples "can not get a license" do
|
||||
|
@ -111,4 +111,4 @@ describe LogStash::LicenseChecker::ModuleLicenseChecker do
|
|||
include_examples "can not get a license"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -70,7 +70,7 @@ describe LogStash::Inputs::Metrics do
|
|||
let(:number_of_events) { 20 }
|
||||
let(:config) { "input { generator { count => #{number_of_events} } } output { null { } }" }
|
||||
|
||||
let(:pipeline_settings) { LogStash::SETTINGS.clone.merge({
|
||||
let(:pipeline_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone.merge({
|
||||
"pipeline.id" => "main",
|
||||
"config.string" => config,
|
||||
}) }
|
||||
|
@ -184,7 +184,7 @@ describe LogStash::Inputs::Metrics do
|
|||
let(:license_subject) { subject { described_class.new(options) }}
|
||||
let(:license_reader) { LogStash::LicenseChecker::LicenseReader.new(system_settings, 'monitoring', es_options)}
|
||||
let(:extension) { LogStash::MonitoringExtension.new }
|
||||
let(:system_settings) { LogStash::SETTINGS.clone }
|
||||
let(:system_settings) { LogStash::Runner::SYSTEM_SETTINGS.clone }
|
||||
let(:license_status) { 'active'}
|
||||
let(:license_type) { 'trial' }
|
||||
let(:license_expiry_date) { Time.now + (60 * 60 * 24)}
|
||||
|
|
34
x-pack/src/test/java/org/logstash/xpack/test/RSpecTests.java
Normal file
34
x-pack/src/test/java/org/logstash/xpack/test/RSpecTests.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package org.logstash.xpack.test;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import org.jruby.runtime.builtin.IRubyObject;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.logstash.RubyUtil;
|
||||
import org.logstash.Rubyfier;
|
||||
|
||||
public final class RSpecTests {
|
||||
@Test
|
||||
public void rspecTests() throws Exception {
|
||||
RubyUtil.RUBY.getENV().put("IS_JUNIT_RUN", "true");
|
||||
RubyUtil.RUBY.getGlobalVariables().set(
|
||||
"$JUNIT_ARGV", Rubyfier.deep(RubyUtil.RUBY, Arrays.asList(
|
||||
"-fd", "--pattern", "spec/**/*_spec.rb"
|
||||
))
|
||||
);
|
||||
final Path rspec = Paths.get(
|
||||
org.assertj.core.util.Files.currentFolder().getParent(), "lib/bootstrap/rspec.rb"
|
||||
);
|
||||
final IRubyObject result = RubyUtil.RUBY.executeScript(
|
||||
new String(Files.readAllBytes(rspec), StandardCharsets.UTF_8),
|
||||
rspec.toFile().getAbsolutePath()
|
||||
);
|
||||
if (!result.toJava(Long.class).equals(0L)) {
|
||||
Assert.fail("RSpec test suit saw at least one failure.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue