From 7d1adb8aa827cf12c501c0e5a7633d902b5c18bc Mon Sep 17 00:00:00 2001 From: AsafMah Date: Wed, 1 Jun 2022 18:43:28 +0300 Subject: [PATCH] Upgrade java version to 3.1.1 (#39) * Upgrade java version to 3.1.1 --- .github/workflows/build.yml | 54 +++++++++++++------------- Gemfile | 2 + README.md | 2 + Rakefile | 2 +- lib/logstash/outputs/kusto/ingestor.rb | 8 ++-- logstash-output-kusto.gemspec | 5 ++- spec/outputs/kusto_spec.rb | 5 +-- spec/spec_helpers.rb | 2 +- 8 files changed, 41 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0878fc0..7b66d82d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,51 +12,49 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - logstash-version: ['6.7', '6.8', '7.0', '7.x', 'default' ] + logstash: [ + { version: '7.17.4', url: "https://artifacts.elastic.co/downloads/logstash/logstash-7.17.4-linux-x86_64.tar.gz" , main: 'true' }, + { version: '6.8.23', url: "https://artifacts.elastic.co/downloads/logstash/logstash-6.8.23.tar.gz" , main: 'false' }, + { version: '8.2.2', url: "https://artifacts.elastic.co/downloads/logstash/logstash-8.2.2-linux-x86_64.tar.gz" , main: 'false' } + ] env: LOGSTASH_SOURCE: 1 - LOGSTASH_PATH: ..//logstash + LOGSTASH_PATH: /home/runner/logstash + JRUBY_HOME: /home/runner/logstash/vendor/jruby steps: - - if: matrix.logstash-version != 'default' - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - uses: ruby/setup-ruby@v1 - with: - ruby-version: jruby - bundler-cache: true - - if: matrix.logstash-version != 'default' - name: Checkout logstash ${{ matrix.logstash-version }} - uses: actions/checkout@v2 - with: - repository: "elastic/logstash" - ref: ${{ matrix.logstash-version }} - path: logstash - - if: matrix.logstash-version != 'default' - name: Build logstash - run: ./gradlew assemble - working-directory: logstash + - name: Build logstash + run: | + echo "Getting logstash version ${{matrix.logstash.version}}" + wget -O logstash.tar.gz ${{matrix.logstash.url}} + tar -xf logstash.tar.gz + mv logstash*/ logstash + working-directory: /home/runner + - name: Set Path + run: | + echo "$LOGSTASH_PATH/bin" >> $GITHUB_PATH + echo "$LOGSTASH_PATH/vendor/jruby/bin" >> $GITHUB_PATH + - name: Install bundler + run: jruby -S gem install bundler - name: Checkout code uses: actions/checkout@v2 with: path: 'kusto' - - run: bundle install + - run: ruby -S bundle install working-directory: 'kusto' - name: Test - run: bundle exec rake spec_junit + run: ruby -S bundle exec rake spec_junit working-directory: 'kusto' - - run: gem build *.gemspec + - run: ruby -S gem build *.gemspec working-directory: 'kusto' - run: mv *.gem logstash-kusto.gem working-directory: 'kusto' - - if: matrix.logstash-version == 'default' + - if: matrix.logstash.main == 'true' name: Upload gem uses: actions/upload-artifact@v2 with: name: logstash-kusto.gem path: 'kusto/logstash-kusto.gem' - - if: matrix.logstash-version == 'default' + - if: matrix.logstash.main == 'true' name: Publish Unit Test Results uses: EnricoMi/publish-unit-test-result-action@v1.6 with: @@ -98,4 +96,4 @@ jobs: APP_ID: ${{ secrets.APP_ID }} APP_KEY: ${{ secrets.APP_KEY }} TENANT_ID: ${{ secrets.TENANT_ID }} - TEST_DATABASE: ${{ secrets.TEST_DATABASE }} \ No newline at end of file + TEST_DATABASE: ${{ secrets.TEST_DATABASE }} diff --git a/Gemfile b/Gemfile index 3c188d0f..b5d8c0c9 100644 --- a/Gemfile +++ b/Gemfile @@ -14,6 +14,8 @@ if Dir.exist?(logstash_path) && use_logstash_source gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api" else puts "using default logstash" + gem 'logstash-core' + gem 'logstash-core-plugin-api' end gem "rspec" diff --git a/README.md b/README.md index 97b7785c..514ac2cc 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ More information about configuring Logstash can be found in the [logstash config - JRuby 9.2 or higher, defined with openjdk 8 64bit - Logstash, defined with openjdk 8 64bit +*It is reccomened to use the bundled jdk and jruby with logstash to avoid compatibility issues.* + To fully build the gem, run: ```shell diff --git a/Rakefile b/Rakefile index 25618261..c5020af0 100644 --- a/Rakefile +++ b/Rakefile @@ -14,4 +14,4 @@ end RSpec::Core::RakeTask.new(:spec_junit) do |t| t.rspec_opts = '--format RspecJunitFormatter --out rspec.xml' -end \ No newline at end of file +end diff --git a/lib/logstash/outputs/kusto/ingestor.rb b/lib/logstash/outputs/kusto/ingestor.rb index 3dd4412e..773b745c 100644 --- a/lib/logstash/outputs/kusto/ingestor.rb +++ b/lib/logstash/outputs/kusto/ingestor.rb @@ -1,6 +1,6 @@ # encoding: utf-8 -require 'logstash/outputs/base' +require 'logstash/outputs/base' require 'logstash/namespace' require 'logstash/errors' @@ -34,13 +34,13 @@ def initialize(ingest_url, app_id, app_key, app_tenant, database, table, json_ma # Unfortunately there's no way to avoid using the gem/plugin name directly... name_for_tracing = "logstash-output-kusto:#{Gem.loaded_specs['logstash-output-kusto']&.version || "unknown"}" @logger.debug("Client name for tracing: #{name_for_tracing}") - kusto_connection_string.setClientVersionForTracing(name_for_tracing) + kusto_connection_string.setClientVersionForTracing(name_for_tracing) @kusto_client = kusto_java.ingest.IngestClientFactory.createClient(kusto_connection_string) @ingestion_properties = kusto_java.ingest.IngestionProperties.new(database, table) - @ingestion_properties.setIngestionMapping(json_mapping, kusto_java.ingest.IngestionMapping::IngestionMappingKind::Json) - @ingestion_properties.setDataFormat(kusto_java.ingest.IngestionProperties::DATA_FORMAT::json) + @ingestion_properties.setIngestionMapping(json_mapping, kusto_java.ingest.IngestionMapping::IngestionMappingKind::JSON) + @ingestion_properties.setDataFormat(kusto_java.ingest.IngestionProperties::DataFormat::JSON) @delete_local = delete_local @logger.debug('Kusto resources are ready.') diff --git a/logstash-output-kusto.gemspec b/logstash-output-kusto.gemspec index 87bfa12c..5e7acc6a 100644 --- a/logstash-output-kusto.gemspec +++ b/logstash-output-kusto.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = 'logstash-output-kusto' #WATCH OUT: we hardcoded usage of this name in one of the classes. - s.version = '1.0.3' + s.version = '1.0.4' s.licenses = ['Apache-2.0'] s.summary = 'Writes events to Azure Data Explorer (Kusto)' s.description = 'This is a logstash output plugin used to write events to an Azure Data Explorer (a.k.a Kusto)' @@ -28,8 +28,9 @@ Gem::Specification.new do |s| s.add_development_dependency 'flores' s.add_development_dependency 'logstash-input-generator' s.add_development_dependency 'ruby-maven', '~> 3.3.11' + s.add_development_dependency 'rspec_junit_formatter' # Jar dependencies - s.requirements << "jar 'com.microsoft.azure.kusto, kusto-ingest, 2.8.2" + s.requirements << "jar 'com.microsoft.azure.kusto, kusto-ingest, 3.1.1'" s.add_runtime_dependency 'jar-dependencies' end diff --git a/spec/outputs/kusto_spec.rb b/spec/outputs/kusto_spec.rb index 7ef375c5..bba94aa7 100644 --- a/spec/outputs/kusto_spec.rb +++ b/spec/outputs/kusto_spec.rb @@ -1,5 +1,4 @@ # encoding: utf-8 -require 'logstash/devutils/rspec/spec_helper' require 'logstash/outputs/kusto' require 'logstash/codecs/plain' require 'logstash/event' @@ -10,7 +9,7 @@ "ingest_url" => "https://ingest-sdkse2etest.eastus.kusto.windows.net/", "app_id" => "myid", "app_key" => "mykey", - "app_tenant" => "mytenant", + "app_tenant" => "mytenant", "database" => "mydatabase", "table" => "mytable", "json_mapping" => "mymapping" @@ -50,5 +49,5 @@ end end - + end diff --git a/spec/spec_helpers.rb b/spec/spec_helpers.rb index 7eab2c87..e917c528 100644 --- a/spec/spec_helpers.rb +++ b/spec/spec_helpers.rb @@ -18,4 +18,4 @@ $stdout = STDOUT $stderr = STDERR end -end \ No newline at end of file +end