Improved es test, introduced setup and teardown.
This commit is contained in:
parent
a52b2472a8
commit
68f32ab223
2 changed files with 98 additions and 87 deletions
|
@ -138,7 +138,7 @@ job_integration_es_mysql:
|
||||||
- mysql
|
- mysql
|
||||||
script:
|
script:
|
||||||
- export RAILS_ENV=test
|
- export RAILS_ENV=test
|
||||||
- export ES_INDEX="estest.local_zammad_"$RNAME
|
- export ES_INDEX_RAND=true
|
||||||
- export ES_URL="http://localhost:9200"
|
- export ES_URL="http://localhost:9200"
|
||||||
- rake db:drop;
|
- rake db:drop;
|
||||||
- rake db:create
|
- rake db:create
|
||||||
|
@ -154,7 +154,7 @@ job_integration_es_postgresql:
|
||||||
- postgresql
|
- postgresql
|
||||||
script:
|
script:
|
||||||
- export RAILS_ENV=test
|
- export RAILS_ENV=test
|
||||||
- export ES_INDEX="estest.local_zammad_"$RNAME
|
- export ES_INDEX_RAND=true
|
||||||
- export ES_URL="http://localhost:9200"
|
- export ES_URL="http://localhost:9200"
|
||||||
- rake db:drop;
|
- rake db:drop;
|
||||||
- rake db:create
|
- rake db:create
|
||||||
|
|
|
@ -3,14 +3,19 @@ require 'integration_test_helper'
|
||||||
|
|
||||||
class ElasticsearchTest < ActiveSupport::TestCase
|
class ElasticsearchTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
|
setup do
|
||||||
|
|
||||||
# set config
|
# set config
|
||||||
if !ENV['ES_URL']
|
if !ENV['ES_URL']
|
||||||
fail "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
|
fail "ERROR: Need ES_URL - hint ES_URL='http://172.0.0.1:9200'"
|
||||||
end
|
end
|
||||||
Setting.set('es_url', ENV['ES_URL'])
|
Setting.set('es_url', ENV['ES_URL'])
|
||||||
if !ENV['ES_INDEX']
|
if !ENV['ES_INDEX'] && !ENV['ES_INDEX_RAND']
|
||||||
fail "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
|
fail "ERROR: Need ES_INDEX - hint ES_INDEX='estest.local_zammad'"
|
||||||
end
|
end
|
||||||
|
if ENV['ES_INDEX_RAND']
|
||||||
|
ENV['ES_INDEX'] = "es_index_#{rand(999_999_999)}"
|
||||||
|
end
|
||||||
Setting.set('es_index', ENV['ES_INDEX'])
|
Setting.set('es_index', ENV['ES_INDEX'])
|
||||||
|
|
||||||
# Setting.set('es_url', 'http://172.0.0.1:9200')
|
# Setting.set('es_url', 'http://172.0.0.1:9200')
|
||||||
|
@ -89,6 +94,7 @@ class ElasticsearchTest < ActiveSupport::TestCase
|
||||||
updated_by_id: 1,
|
updated_by_id: 1,
|
||||||
created_by_id: 1,
|
created_by_id: 1,
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
||||||
# check tickets and search it
|
# check tickets and search it
|
||||||
test 'a - tickets' do
|
test 'a - tickets' do
|
||||||
|
@ -349,4 +355,9 @@ class ElasticsearchTest < ActiveSupport::TestCase
|
||||||
assert(!result[0], 'record 1')
|
assert(!result[0], 'record 1')
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
system('rake searchindex:drop')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue