Skip to content

Commit

Permalink
Fix race condition on async test for PR opensearch-project#1158 (open…
Browse files Browse the repository at this point in the history
…search-project#1331)

* Fix race condition on async test

(cherry picked from commit dc34c54)
  • Loading branch information
andy840314 committed Jul 27, 2021
1 parent 9648a28 commit 80e3670
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ public void testParallelPutRequests() throws Exception {
boolean created = false;
for (HttpResponse response : responses) {
int sc = response.getStatusCode();
if (sc == HttpStatus.SC_CREATED) {
Assert.assertFalse(created);
created = true;
} else {
Assert.assertEquals(HttpStatus.SC_CONFLICT, sc);
switch (sc) {
case HttpStatus.SC_CREATED:
Assert.assertFalse(created);
created = true;
break;
case HttpStatus.SC_OK:
break;
default:
Assert.assertEquals(HttpStatus.SC_CONFLICT, sc);
break;
}
}
deleteUser("test1");
Expand Down

0 comments on commit 80e3670

Please sign in to comment.