Skip to content

Commit

Permalink
SDKQE-2582: Fix QueryIndexManager integration tests interference fail…
Browse files Browse the repository at this point in the history
…ures

Query Indexes are not being cleaned up after QueryIndexManager tests, which
is causing interference with other tests and erroneous failures when running
the whole suite of tests.

Change-Id: I1a2881d148a467fcb8965d07eaefd7cb87fe8a2e
Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/170901
Tested-by: Build Bot <build@couchbase.com>
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  • Loading branch information
willbroadbelt committed Feb 17, 2022
1 parent 450ee37 commit 3a14e4f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,16 @@ static void setup() throws Exception {

@AfterAll
static void tearDown() {
cleanupIndexes();
cluster.disconnect();
}

@BeforeEach
void cleanup() {
cleanupIndexes();
}

static void cleanupIndexes() {
indexes
.getAllIndexes(bucketName, enrich(getAllQueryIndexesOptions()))
.forEach(idx ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,25 @@ static void setup() {

@AfterAll
static void tearDown() {
cleanupIndexes();
cluster.disconnect();
}

@BeforeEach
void cleanup() {
cleanupIndexes();
}

static void cleanupIndexes() {
indexes.getAllIndexes(bucketName).forEach(idx -> {
indexes.dropIndex(bucketName, idx.name());
if (idx.scopeName().isPresent()) {
indexes.dropIndex(bucketName, idx.name(), DropQueryIndexOptions.dropQueryIndexOptions()
.scopeName(idx.scopeName().get())
.collectionName(idx.collectionName().get())
);
} else {
indexes.dropIndex(bucketName, idx.name());
}
});
assertEquals(emptyList(), indexes.getAllIndexes(bucketName));
}
Expand Down

0 comments on commit 3a14e4f

Please sign in to comment.