mardi 27 octobre 2015

Testing a PHP app with Elasticsearch dependency

Haven't been testing my applications until recently so not much practice nor knowledge on the subject.

Requirement

In my php app, I want to assure the functioning of the following functionality:

  • class xService receives array of filters
  • the class forms filters for an ES search query
  • the class fetches IDs of matching documents from remote ES server
  • the class returns rows from SQL DB with corresponding IDs

Attempted solution

A test run by phpUnit.

1) The test creates models in the SQL DB and indexes them to remote ES server. (input)

2) The test sends an array to xService. (input)

3) Class xService returns rows from database (output/assertion)

Problem

Running the exact same test over and over again, the results vary. I assume this is because sometimes the indexed documents are not yet available when the search query arrives at the ES server (I am using free hosting at Facetflow).

What is the best way to assure this functionality?

Aucun commentaire:

Enregistrer un commentaire