<commit_before>require 'rubygems'
require 'bundler/setup'

require File.expand_path('../../lib/tagalong', __FILE__)

require File.expand_path('spec/support/setup_database')

require 'sunspot_solr'

require 'net/http'

def solr_startup_timeout
  15
end

def solr_running?
  begin
    solr_ping_uri = URI.parse("#{Sunspot.session.config.solr.url}/ping")
    Net::HTTP.get(solr_ping_uri)
    true
  rescue
    false
  end
end

def wait_until_solr_starts
  (solr_startup_timeout * 10).times do
    break if solr_running?
    sleep(0.1)
  end
  raise TimeOutError, "Solr failed to start after #{solr_startup_timeout} seconds" unless solr_running?
end

RSpec.configure do |c|
  c.before(:each) do
    clean_database!
  end

  c.before(:all, :search => true) do
    Sunspot::Solr::Server.new.start
    wait_until_solr_starts
  end

  c.before(:each, :search => true) do
    Sunspot.remove_all!
    Sunspot.commit
  end

  c.after(:all, :search => true) do
    Sunspot::Solr::Server.new.stop
  end
end
<commit_msg>Bumped solr_startup_timeout to 60 secs.<commit_after>require 'rubygems'
require 'bundler/setup'

require File.expand_path('../../lib/tagalong', __FILE__)

require File.expand_path('spec/support/setup_database')

require 'sunspot_solr'

require 'net/http'

def solr_startup_timeout
  60
end

def solr_running?
  begin
    solr_ping_uri = URI.parse("#{Sunspot.session.config.solr.url}/ping")
    Net::HTTP.get(solr_ping_uri)
    true
  rescue
    false
  end
end

def wait_until_solr_starts
  (solr_startup_timeout * 10).times do
    break if solr_running?
    sleep(1)
  end
  raise "Solr failed to start after #{solr_startup_timeout} seconds" unless solr_running?
end

RSpec.configure do |c|
  c.before(:each) do
    clean_database!
  end

  c.before(:all, :search => true) do
    Sunspot::Solr::Server.new.start
    wait_until_solr_starts
  end

  c.before(:each, :search => true) do
    Sunspot.remove_all!
    Sunspot.commit
  end

  c.after(:all, :search => true) do
    Sunspot::Solr::Server.new.stop
  end
end

{'fraction_non_alphanumeric': 0.1132542037586548, 'fraction_numerical': 0.006429277942631058, 'mean_word_length': 3.8864734299516908, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1958453', 'n_tokens_mistral': 773, 'n_tokens_neox': 752, 'n_words': 159}