orpiske commented on code in PR #13341: URL: https://github.com/apache/camel/pull/13341#discussion_r1521241028
########## test-infra/camel-test-infra-ollama/src/test/java/org/apache/camel/test/infra/ollama/services/OllamaContainer.java: ########## @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.test.infra.ollama.services; + +import java.io.IOException; + +import com.github.dockerjava.api.command.InspectContainerResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.output.Slf4jLogConsumer; +import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.utility.DockerImageName; + +public class OllamaContainer extends GenericContainer<OllamaContainer> { + + private static final Logger LOGGER = LoggerFactory.getLogger(OllamaContainer.class); + + private final DockerImageName dockerImageName; + + private final Integer port; + private final String model; + private final String imageName; + + public OllamaContainer(DockerImageName image, Integer port, String model, String imageName) { + super(image); + + this.dockerImageName = image; + this.port = port; + this.model = model; + this.imageName = imageName; + withExposedPorts(port); + withImagePullPolicy(dockerImageName -> !dockerImageName.getVersionPart().endsWith(model)); + setWaitStrategy(Wait.forListeningPort()); + withLogConsumer(new Slf4jLogConsumer(LOGGER)); + } + + @Override + protected void containerIsStarted(InspectContainerResponse containerInfo) { + if (!this.dockerImageName.equals(DockerImageName.parse(imageName))) { + try { + LOGGER.info("Start pulling the '{}' model ... would take several minutes ...", model); Review Comment: You can annotate the tests with the following annotation to prevent them from running on CI environments (ASF or Github): `@DisabledIfSystemProperty(named = "ci.env.name", matches = "*", disabledReason = "Requires too much network resources")` The idea is to prevent ASF or Github from abusing the host that serves this model. It would still run locally, though. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org