File: benchmarker.rb

package info (click to toggle)
puppet-agent 8.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,392 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (38 lines) | stat: -rw-r--r-- 823 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require 'fileutils'

class Benchmarker
  include FileUtils

  def initialize(target, size)
    @target = target
    @size = size > 1000 ? size : 1000
  end

  def setup
    require 'puppet'
    @config = File.join(@target, 'puppet.conf')
    Puppet.initialize_settings(['--config', @config])
  end

  def run(args=nil)
    Puppet.settings.clear
    environment_loaders = Puppet.lookup(:environments)
    environment_loaders.clear_all
    environment_loaders.get!("anenv#{@size/2}")
  end

  def generate
    environments = File.join(@target, 'environments')
    puppet_conf = File.join(@target, 'puppet.conf')

    File.open(puppet_conf, 'w') do |f|
      f.puts(<<-EOF)
        environmentpath=#{environments}
      EOF
    end

    @size.times do |i|
      mkdir_p(File.join(environments, "anenv#{i}"))
    end
  end
end