Skip to content

Commit a670973

Browse files
RMB-1030: CachedConnectionManager can return permission denied for schema (#1204)
* Better recovery from error state * Ensures cache object is reused rather than recreated Co-authored-by: Olamide Kolawole <okolawole@ebsco.com>
1 parent 925d5e3 commit a670973

14 files changed

Lines changed: 906 additions & 95 deletions

File tree

domain-models-runtime-it/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@
5757
<scope>test</scope>
5858
</dependency>
5959

60+
<dependency>
61+
<groupId>org.awaitility</groupId>
62+
<artifactId>awaitility</artifactId>
63+
<version>${awaitility.version}</version>
64+
<scope>test</scope>
65+
</dependency>
66+
6067
</dependencies>
6168

6269
<build>

domain-models-runtime-it/src/test/java/org/folio/rest/ApiTestBase.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import java.util.concurrent.ExecutionException;
1111
import java.util.concurrent.TimeUnit;
1212
import java.util.concurrent.TimeoutException;
13+
import java.util.concurrent.atomic.AtomicReference;
1314
import io.restassured.RestAssured;
1415
import io.restassured.filter.log.ErrorLoggingFilter;
1516
import io.restassured.http.ContentType;
@@ -18,6 +19,7 @@
1819
import io.vertx.core.Vertx;
1920
import io.vertx.core.json.Json;
2021
import io.vertx.core.json.JsonObject;
22+
import org.awaitility.Awaitility;
2123
import org.folio.postgres.testing.PostgresTesterContainer;
2224
import org.folio.rest.jaxrs.model.Parameter;
2325
import org.folio.rest.jaxrs.model.TenantAttributes;
@@ -66,24 +68,14 @@ static void beforeAll() {
6668

6769
// delete tenant (schema, tables, ...) if it exists from previous tests
6870
TenantAttributes ta = new TenantAttributes().withPurge(true);
69-
given(r).header("x-okapi-url-to", "http://localhost:" + port).
70-
contentType(ContentType.JSON)
71-
.body(Json.encode(ta))
72-
.when().post("/_/tenant")
73-
.then().statusCode(204);
71+
postTenantWithRetry(ta, 204);
7472

7573
List<Parameter> list = new LinkedList<>();
7674
list.add(new Parameter().withKey("loadReference").withValue("true"));
7775
ta = new TenantAttributes().withModuleTo("mod-api-1.0.0").withParameters(list);
7876

7977
// create tenant (schema, tables, ...)
80-
String location = given(r)
81-
.header("x-okapi-url-to", "http://localhost:" + port)
82-
.contentType(ContentType.JSON)
83-
.body(Json.encode(ta))
84-
.when().post("/_/tenant")
85-
.then().statusCode(201)
86-
.extract().header("Location");
78+
String location = postTenantWithRetry(ta, 201);
8779

8880
given(r)
8981
.header("x-okapi-url-to", "http://localhost:" + port)
@@ -94,6 +86,22 @@ static void beforeAll() {
9486
.body("error", is(nullValue()));
9587
}
9688

89+
private static String postTenantWithRetry(TenantAttributes tenantAttributes, int expectedStatus) {
90+
var location = new AtomicReference<String>();
91+
Awaitility.await().untilAsserted(() -> location.set(
92+
given(r)
93+
.header("x-okapi-url-to", "http://localhost:" + port)
94+
.contentType(ContentType.JSON)
95+
.body(Json.encode(tenantAttributes))
96+
.when()
97+
.post("/_/tenant")
98+
.then()
99+
.statusCode(expectedStatus)
100+
.extract()
101+
.header("Location")));
102+
return location.get();
103+
}
104+
97105
/**
98106
* @param path API path, for example <code>/bees</code>
99107
* @param arrayName property name of the result array, for example <code>bees</code>

0 commit comments

Comments
 (0)