-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support multiple URLs in connection string
the underlying OpenSearch library supports multiple URLs, thus we should do the same here as well. since Liquibase has no concept of this on its own we have to use a workaround and use a character to concatenate multiple URLs together. `,` is being used for this as it's normally not part of URLs and it's already used in the OpenSearch client for this purpose. the `opensearch:` prefix should not be repeated. i.e. a URL with multiple addresses should be defined like this: ``` opensearch:http://localhost:9200,http://localhost:9201,http://localhost:9203 ``` the login information is the same for all, since they must form a cluster.
- Loading branch information
Showing
4 changed files
with
69 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/test/java/liquibase/ext/opensearch/MultipleOpenSearchNodesLiquibaseIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package liquibase.ext.opensearch; | ||
|
||
import liquibase.database.DatabaseFactory; | ||
import liquibase.ext.opensearch.database.OpenSearchConnection; | ||
import liquibase.ext.opensearch.database.OpenSearchLiquibaseDatabase; | ||
import lombok.SneakyThrows; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class MultipleOpenSearchNodesLiquibaseIT extends AbstractOpenSearchLiquibaseIT { | ||
@SneakyThrows | ||
@BeforeEach | ||
@Override | ||
protected void beforeEach() { | ||
// if we launch two testcontainers they can't see each other and thus don't form a cluster => just use the same URL twice to show that it's being accepted | ||
// note: don't use the constants here to detect if we ever change them (to make sure that we actively decide on doing a breaking change rather than making it by mistake). | ||
final String url = "opensearch:" + this.container.getHttpHostAddress() + "," + this.container.getHttpHostAddress(); | ||
final String username = container.getUsername(); | ||
final String password = container.getPassword(); | ||
database = (OpenSearchLiquibaseDatabase) DatabaseFactory.getInstance().openDatabase(url, username, password, null, null); | ||
connection = (OpenSearchConnection) this.database.getConnection(); | ||
} | ||
|
||
@SneakyThrows | ||
@Test | ||
void itCreatesTheChangelogAndLockIndices() { | ||
this.doLiquibaseUpdate("liquibase/ext/changelog.empty.yaml"); | ||
assertThat(this.indexExists(this.database.getDatabaseChangeLogLockTableName())).isTrue(); | ||
assertThat(this.indexExists(this.database.getDatabaseChangeLogTableName())).isTrue(); | ||
} | ||
|
||
} |