This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'es_spec_helper' | |
| RSpec.describe 'ES search' do | |
| before :all do | |
| #Generate test data in db, using FactoryGirl for example | |
| Integrations::EsSpecHelper.create_index(name: 'test_index', mapping: INDEX_DEFINITION) | |
| #Use ETL to load data | |
| SampleETL.populate_index('test_index') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencies: | |
| post: | |
| - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.0.tar.gz | |
| - tar -xvf elasticsearch-5.3.0.tar.gz | |
| - elasticsearch-5.3.0/bin/elasticsearch: {background: true} | |
| # Make sure that Elasticsearch is up before running tests: | |
| - sleep 10 && wget --waitretry=5 --retry-connrefused -v http://127.0.0.1:9200/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Integrations::EsSpecHelper.remove_index(name: 'test_index') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ESClient.search( | |
| index: 'test_index', | |
| body: your_generated_query) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Integrations::EsSpecHelper.flush_index(name: 'test_index') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Integrations::EsSpecHelper.create_index(name: 'test_index', mapping: INDEX_DEFINITION) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| INDEX_DEFINITION = { | |
| mappings: { | |
| sample: { | |
| properties: { | |
| message: { | |
| type: 'text', | |
| analyzer: 'standard' | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Integrations | |
| module EsSpecHelper | |
| def self.create_index(name:, mapping:) | |
| ESClient.indices.create(index: name, body: mapping) | |
| end | |
| def self.remove_index(name:) | |
| ESClient.indices.delete index: name | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ESClient = Elasticsearch::Client.new(url: ‘http://localhost:9200') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 14 15 * * |