Sha256: d5050e73dcd8ccdc85ddef4bb12f105da204748fe4d9a83e0755de6f60b3ba6a

Contents?: true

Size: 1.93 KB

Versions: 9

Compression:

Stored size: 1.93 KB

Contents

# frozen_string_literal: true
[
  File.join(File.dirname(__FILE__), '..'),
  File.join(File.dirname(__FILE__), '..', 'lib/fluent/plugin'),
  File.join(File.dirname(__FILE__), '..', 'spec'),
].each do |dir|
  $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
end

require 'elastic_metrics_parser'
require 'date'
require 'rspec'


RSpec.describe ElasticMetricsParser do
  describe "#emit_parsed_metrics" do
    it 'should read sample Artifactory metrics data and verify the size of parsed data > 1' do
      platform_metrics = File.read('./spec/fixtures/files/sample_artifactory_metrics.txt')
      expect(platform_metrics.size).to be > 1

      parser = ElasticMetricsParser.new('jfrog.artifactory', '', 'jfrog.artifactory.metrics')

      normalized_data = parser.normalise_data(platform_metrics)
      expect(normalized_data.size).to be > 1

      cleaned_data = parser.clean_data(normalized_data)
      expect(cleaned_data.size).to be > 1

      hash_data_array = parser.extract_metrics_in_hash(cleaned_data, 'jfrog.artifactory', '.')
      expect(hash_data_array.size).to be > 1

      serialized_data = parser.serialize_data(hash_data_array)
      expect(serialized_data.size).to be > 1
    end

    it 'should read sample Xray metrics data and verify the size of parsed data > 1' do
      platform_metrics = File.read('./spec/fixtures/files/sample_xray_metrics.txt')
      expect(platform_metrics.size).to be > 1

      parser = ElasticMetricsParser.new('jfrog.xray', '', 'jfrog.xray.metrics')

      normalized_data = parser.normalise_data(platform_metrics)
      expect(normalized_data.size).to be > 1

      cleaned_data = parser.clean_data(normalized_data)
      expect(cleaned_data.size).to be > 1

      hash_data_array = parser.extract_metrics_in_hash(cleaned_data, 'jfrog.xray', '.')
      expect(hash_data_array.size).to be > 1

      serialized_data = parser.serialize_data(hash_data_array)
      expect(serialized_data.size).to be > 1
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fluent-plugin-jfrog-metrics-0.2.8 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.7 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.6 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.5 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.4 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.3 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.2 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.1 spec/lib/elastic_metrics_parser_spec.rb
fluent-plugin-jfrog-metrics-0.2.0 spec/lib/elastic_metrics_parser_spec.rb