-
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. 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
67 additions
and
12 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
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
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; | ||
|
||
public 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 | ||
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 | ||
public void itCreatesTheChangelogAndLockIndices() { | ||
this.doLiquibaseUpdate("liquibase/ext/changelog.empty.yaml"); | ||
assertThat(this.indexExists(this.database.getDatabaseChangeLogLockTableName())).isTrue(); | ||
assertThat(this.indexExists(this.database.getDatabaseChangeLogTableName())).isTrue(); | ||
} | ||
|
||
} |