Ollama integration tests fix

* Disable tests by default
* Improve Testcontainers configuration
This commit is contained in:
Thomas Vitale
2024-10-15 06:53:26 +02:00
committed by Christian Tzolov
parent f004ee7d35
commit f0f3501f8e
2 changed files with 4 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ public class BaseOllamaIT {
private static final Logger logger = LoggerFactory.getLogger(BaseOllamaIT.class);
// Toggle for running tests locally on native Ollama for a faster feedback loop.
private static final boolean useTestcontainers = false;
private static final boolean useTestcontainers = true;
public static final OllamaContainer ollamaContainer;
@@ -30,13 +30,13 @@ public class BaseOllamaIT {
* to the file ".testcontainers.properties" located in your home directory
*/
public static boolean isDisabled() {
return false;
return true;
}
public static OllamaApi buildOllamaApiWithModel(String model) {
var baseUrl = "http://localhost:11434";
if (useTestcontainers) {
baseUrl = "http://" + ollamaContainer.getHost() + ":" + ollamaContainer.getMappedPort(11434);
baseUrl = ollamaContainer.getEndpoint();
}
var ollamaApi = new OllamaApi(baseUrl);

View File

@@ -37,7 +37,7 @@ public class BaseOllamaIT {
public static String buildConnectionWithModel(String model) throws IOException, InterruptedException {
var baseUrl = "http://localhost:11434";
if (useTestcontainers) {
baseUrl = "http://" + ollamaContainer.getHost() + ":" + ollamaContainer.getMappedPort(11434);
baseUrl = ollamaContainer.getEndpoint();
logger.info("Start pulling the '{}' model. The operation can take several minutes...", model);
ollamaContainer.execInContainer("ollama", "pull", model);