<commit_before>require 'thread'

module CfCanaries
  GO_BUILDPACK='git://github.com/vito/heroku-buildpack-go.git'

  class Breeder
    def initialize(options)
      @options = options
    end

    def breed(logger, runner)
      logger.info 'targeting and logging in'
      runner.run!("gcf api #{@options.target}")
      runner.run!("gcf login -u '#{@options.username}' -p '#{@options.password}' -o #{@options.organization} -s #{@options.space}")

      logger.info 'breeding canaries'

      push_zero_downtime_canary(logger, runner)
      push_aviary(logger, runner)
      push_cpu_canary(logger, runner)
      push_disk_canary(logger, runner)
      push_memory_canary(logger, runner)
      push_network_canary(logger, runner)
      push_instances_canary(logger, runner)

      logger.info 'TWEET TWEET'
    end

    private

    def push_zero_downtime_canary(logger, runner)
      number_of_canaries = @options.number_of_zero_downtime_apps

      logger.info "pushing #{number_of_canaries} zero-downtime canaries"

      number_of_canaries.times do |i|
        push_app(logger, runner, "zero-downtime-canary#{i + 1}", {},
                 directory_name: 'zero-downtime',
                 buildpack: GO_BUILDPACK)
      end
    end

    def push_aviary(logger, runner)
      env = {
        TARGET: @options.target,
        USERNAME: @options.username,
        PASSWORD: @options.password,
        DOMAIN: @options.app_domain,
        NUM_INSTANCES: @options.number_of_zero_downtime_apps
      }

      push_app(logger, runner, 'aviary', env)
    end

    def push_cpu_canary(logger, runner)
      push_app(logger, runner, 'cpu', {}, memory: '512M')
    end

    def push_disk_canary(logger, runner)
      push_app(logger, runner, 'disk', {SPACE: '768'}, memory: '2G')
    end

    def push_memory_canary(logger, runner)
      push_app(logger, runner, 'memory', {MEMORY: '112M'})
    end

    def push_network_canary(logger, runner)
      push_app(logger, runner, 'network', {}, buildpack: GO_BUILDPACK)
    end

    def push_instances_canary(logger, runner)
      push_app(
        logger, runner, 'instances-canary', {},
        instances: @options.number_of_instances_canary_instances,
        memory: '128M',
        directory_name: 'instances'<commit_msg>Pass separate zero-downtime and instance-canary app counts to aviary app.<commit_after>require 'thread'

module CfCanaries
  GO_BUILDPACK='git://github.com/vito/heroku-buildpack-go.git'

  class Breeder
    def initialize(options)
      @options = options
    end

    def breed(logger, runner)
      logger.info 'targeting and logging in'
      runner.run!("gcf api #{@options.target}")
      runner.run!("gcf login -u '#{@options.username}' -p '#{@options.password}' -o #{@options.organization} -s #{@options.space}")

      logger.info 'breeding canaries'

      push_zero_downtime_canary(logger, runner)
      push_aviary(logger, runner)
      push_cpu_canary(logger, runner)
      push_disk_canary(logger, runner)
      push_memory_canary(logger, runner)
      push_network_canary(logger, runner)
      push_instances_canary(logger, runner)

      logger.info 'TWEET TWEET'
    end

    private

    def push_zero_downtime_canary(logger, runner)
      number_of_canaries = @options.number_of_zero_downtime_apps

      logger.info "pushing #{number_of_canaries} zero-downtime canaries"

      number_of_canaries.times do |i|
        push_app(logger, runner, "zero-downtime-canary#{i + 1}", {},
                 directory_name: 'zero-downtime',
                 buildpack: GO_BUILDPACK)
      end
    end

    def push_aviary(logger, runner)
      env = {
        TARGET: @options.target,
        USERNAME: @options.username,
        PASSWORD: @options.password,
        DOMAIN: @options.app_domain,
        NUM_INSTANCES: @options.number_of_zero_downtime_apps,
        ZERO_DOWNTIME_NUM_INSTANCES: @options.number_of_zero_downtime_apps,
        INSTANCES_CANARY_NUM_INSTANCES: @options.number_of_instances_canary_instances,
      }

      push_app(logger, runner, 'aviary', env)
    end

    def push_cpu_canary(logger, runner)
      push_app(logger, runner, 'cpu', {}, memory: '512M')
    end

    def push_disk_canary(logger, runner)
      push_app(logger, runner, 'disk', {SPACE: '768'}, memory: '2G')
    end

    def push_memory_canary(logger, runner)
      push_app(logger, runner, 'memory', {MEMORY: '112M'})
    end

    def push_network_canary(logger, runner)
      push_app(logger, runner, 'network', {}, buildpack: GO_BUILDPACK)
    end

    def push_instances_canary(logger, runner)
      push_app(
        logger, runner, 'instances-canary', {},
        instances: @options.number_of_instances_canary_instances,
        memory: '128M',
        directory_name: 'instances'
{'fraction_non_alphanumeric': 0.11069023569023569, 'fraction_numerical': 0.005892255892255892, 'mean_word_length': 3.1876651982378856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1431410', 'n_tokens_mistral': 1644, 'n_tokens_neox': 1556, 'n_words': 308}