Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [kapua-dev] Fixing datastore unit tests

I agree about refresh, I read somewhere on ES site that refresh method is meant just for that – for testing.

I will introduce it to datastore tests which are refactored together with Riccardo right now.

 

Uroš

 

 

From: "kapua-dev-bounces@xxxxxxxxxxx" <kapua-dev-bounces@xxxxxxxxxxx> on behalf of Jens Reimann <jreimann@xxxxxxxxxx>
Reply-To: kapua developer discussions <kapua-dev@xxxxxxxxxxx>
Date: Monday, 24 April 2017 at 11:35
To: kapua developer discussions <kapua-dev@xxxxxxxxxxx>
Subject: [kapua-dev] Fixing datastore unit tests

 

Hi everyone,

while trying to build some unit tests around the simulator, pushing data to Kapua I ran into the same issue, that data published to Elasticsearch (ES) is not present for querying after publishing.

So I remembered the discussion a little bit back about timeouts and stuff, and how this is different between the different machines.

However, looking at Google there seems to be a very simple solution for this: refresh the indices!

The following code snippet does a simple HTTP call, which triggers ES to refresh _all_ indices and this allows to query right away:

---
HttpPost request = new HttpPost("http://localhost:9200/_refresh");
try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
  try (CloseableHttpResponse response = client.execute(request)) {
  }
}
---

I added this to the "kapua-qa" project as a simple method and step, pushing this in the next few days.

However we still have the issue that, directly after publishing data over the broker, the broker may need "a bit" of time before we can actually refresh. But directly calling datastore APIs should not have this limitation.

 

Maybe someone more familiar ES could check if this is the right approach, but it works fine for me. Not relying on any dynamic timeout.

Thanks

Jens


--

Jens Reimann
Senior Software Engineer / EMEA ENG Middleware
Werner-von-Siemens-Ring 14
85630 Grasbrunn
Germany
phone: +49 89 2050 71286
_____________________________________________________________________________

Red Hat GmbH, www.de.redhat.com,
Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Paul Argiry, Charles Cachera, Michael Cunningham, Michael O'Neill


Back to the top