Sha256: abdc1506ad35049c62e85ff512e4b4e71cfa05cc3eea8780501ceb3c036cb405

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 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 'newrelic_metrics_sender'
require 'date'
require 'rspec'
require 'rest-client'
require './spec/fixtures/files/creds'


RSpec.describe NewRelicMetrics do
  newrelic_apikey = get_newrelic_credentials
  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_newrelic_metrics.txt')
      puts platform_metrics.class
      expect(platform_metrics.size).to be > 1

      response = RestClient::Request.new(
          method: :post,
          url: "https://metric-api.newrelic.com/metric/v1",
          payload: platform_metrics,
          headers: {params: {'Api-Key' => newrelic_apikey, "Content-Type" => "application/json"}}
      ).execute do |response, request, result|
        puts response
        expect(response.code).to eq(202)
        expect(response.size).to be > 1
      end
    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_newrelic_metrics.txt')
      expect(platform_metrics.size).to be > 1

      response = RestClient::Request.new(
          method: :post,
          url: "https://metric-api.newrelic.com/metric/v1",
          payload: platform_metrics,
          headers: {params: {'Api-Key' => newrelic_apikey, "Content-Type" => "application/json"}}
      ).execute do |response, request, result|
        puts response
        expect(response.code).to eq(202)
        expect(response.size).to be > 1
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-jfrog-send-metrics-0.1.0 spec/lib/newrelic_metrics_sender_spec.rb