Sha256: 0e05fec7a5c8068f8eb852cce1ecca60cdbf2320a904f31f01dfd39e69fae53a

Contents?: true

Size: 1.62 KB

Versions: 13

Compression:

Stored size: 1.62 KB

Contents

require_relative './spec_helper'

require 'norikra/stats'
require 'norikra/server'

require 'tmpdir'

describe Norikra::Stats do
  describe '#to_hash' do
    it 'returns internal stats as hash with symbolized keys' do
      args = {
        host: nil,
        port: nil,
        ui_port: nil,
        threads: Norikra::Server::SMALL_PREDEFINED,
        log: {level: nil, dir: nil, filesize: nil, backups: nil},
        targets: [],
        queries: [],
      }
      s = Norikra::Stats.new(args)
      expect(s.to_hash).to eql(args)
    end
  end

  describe '.load' do
    it 'can restore stats data from #dump -ed json' do
      Dir.mktmpdir do |dir|
        File.open("#{dir}/stats.json", 'w') do |file|
          args = {
            host: nil,
            port: nil,
            ui_port: nil,
            threads: Norikra::Server::LARGE_PREDEFINED,
            log: {level: 'WARN', dir: '/var/log/norikra', filesize: '50MB', backups: 300},
            targets: [
              { name: 'test1', fields: { id: { name: 'id', type: 'int', optional: false}, data: { name: 'data', type: 'string', optional: true } } },
            ],
            queries: [
              { name: 'testq2', expression: 'select count(*) from test1.win:time(5 sec)' },
              { name: 'testq1', expression: 'select count(*) from test1.win:time(10 sec)' },
            ],
          }
          s1 = Norikra::Stats.new(args)
          expect(s1.to_hash).to eql(args)

          s1.dump(file.path)

          s2 = Norikra::Stats.load(file.path)
          expect(s2.to_hash).to eql(s1.to_hash)
          expect(s2.to_hash).to eql(args)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
norikra-0.1.4-java spec/stats_spec.rb
norikra-0.1.3-java spec/stats_spec.rb
norikra-0.1.2-java spec/stats_spec.rb
norikra-0.1.1-java spec/stats_spec.rb
norikra-0.1.0-java spec/stats_spec.rb
norikra-0.0.24-java spec/stats_spec.rb
norikra-0.0.23-java spec/stats_spec.rb
norikra-0.0.22-java spec/stats_spec.rb
norikra-0.0.21-java spec/stats_spec.rb
norikra-0.0.20-java spec/stats_spec.rb
norikra-0.0.19-java spec/stats_spec.rb
norikra-0.0.18-java spec/stats_spec.rb
norikra-0.0.17-java spec/stats_spec.rb