worker_spec.rb revision 20d7141b5fbf4ea48eeadae9d6a9a88465ac6b8b
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlenrequire 'spec_helper'
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen# We try to be explicit when using sidekiq
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen# testing modes. However inline! is the default
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen let(:balancer) { ConcurrencyBalancer.new }
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen let(:ontology) { create :single_unparsed_ontology, iri: 'http://example.com/test/sequential_parse' }
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen balancer.mark_as_finished_processing(ontology.iri)
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen rescue ConcurrencyBalancer::UnmarkedProcessingError
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen balancer.mark_as_processing_or_complain(ontology.iri)
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen OntologyVersion.any_instance.stubs(:raw_path!).returns(
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen Rails.root + 'test/fixtures/ontologies/clif/sequential_parse.clif')
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen balancer.mark_as_finished_processing(ontology.iri)
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen OntologyVersion.any_instance.unstub(:raw_path!)
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen context 'exceeding the parallel try count of an already marked iri job' do
6fb29c51593eb4622f537cd43c1a81ffb36a8ff7Knut Anders Hatlen it 'should put the correct job in the sequential queue' do
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen rest_args = ['record', OntologyVersion.to_s, 'parse', version.id]
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen *rest_args, try_count: ConcurrencyBalancer::MAX_TRIES)
6fd168587048fe0e2cb37acdcc9ae9764c83b2d2Trond Norbye expect(SequentialWorker.jobs.first['args']).to eq([*rest_args])
eb11fe3584b7b243fb0641da4ab2e157610bb767Lubos Kosco context 'not exceeding the parallel try count of an already marked iri job' do
eb11fe3584b7b243fb0641da4ab2e157610bb767Lubos Kosco it 'should put the correct job in the queue once again' do
eb11fe3584b7b243fb0641da4ab2e157610bb767Lubos Kosco rest_args = ['record', OntologyVersion.to_s, 'parse', version.id]
722820d7fc7cef11b744d2c2a9e680cee7d292ffAsCatgz *rest_args, try_count: ConcurrencyBalancer::MAX_TRIES-1)
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen # We need the String-Hash-Key syntax, because
ca13a2073cb9936daab594cd277550783ac2e6b6Knut Anders Hatlen # the JSON generate/parse cycle does not support