<commit_before>require "test_helper"
class ClusterTest < MiniTest::Unit::TestCase
  def setup
    Mobilize::Cluster.perform    "terminate"
  end

  def test_spin_up
    Mobilize::Cluster.perform    "install"
    Mobilize::Cluster.perform    "start"

    #wait for workers to rev up
    _resque_web_workers          = Mobilize::Cluster.resque_web_workers
    _workers_per_engine          = Mobilize.config.cluster.engines.workers.count
    _engines                     = Mobilize::Cluster.engines

    _engines.each do |_engine|
      _key                       = "ip-#{ _engine.ip }".pretty_key
      assert_equal                 _resque_web_workers[ _key ],
                                   _workers_per_engine.to_s
    end
    _total_workers               = _workers_per_engine * _engines.length
    assert_equal                   _resque_web_workers[ :all_workers ], _total_workers.to_s

  end

  def teardown
    #Mobilize::Cluster.perform "terminate"
  end
end<commit_msg>cluster test works<commit_after>require "test_helper"
class ClusterTest < MiniTest::Unit::TestCase
  def setup
    Mobilize::Cluster.perform    "terminate"
  end

  def test_spin_up
    Mobilize::Cluster.perform    "install"
    Mobilize::Cluster.perform    "start"

    _workers_per_engine          = Mobilize.config.cluster.engines.workers.count
    _engines                     = Mobilize::Cluster.engines

    _resque_web_workers          = Mobilize::Cluster.resque_web_workers
    #wait for workers to start
    _attempts                    = 0
    while _resque_web_workers.length < _engines.length and _attempts <= 5
      Mobilize::Logger.write       "waiting for workers on all engines"
      _resque_web_workers        = Mobilize::Cluster.resque_web_workers
      sleep 5
      _attempts                 += 1
    end

    raise "Worker engine start failed" if _resque_web_workers.length <= _engines.length

    _engines.each do |_engine|
      _key                       = "ip-#{ _engine.ip }".pretty_key
      assert_equal                 _resque_web_workers[ _key ],
                                   _workers_per_engine.to_s
    end
    _total_workers               = _workers_per_engine * _engines.length
    assert_equal                   _resque_web_workers[ :all_workers ], _total_workers.to_s

  end

  def teardown
    Mobilize::Cluster.perform "terminate"
  end
end
{'fraction_non_alphanumeric': 0.06849894291754757, 'fraction_numerical': 0.0016913319238900633, 'mean_word_length': 2.146276595744681, 'pattern_counts': {'":': 0, '<': 8, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5420835', 'n_tokens_mistral': 727, 'n_tokens_neox': 705, 'n_words': 138}