-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subid image does not override id image in xtf properties #571
Comments
I'm ok with this change. Current logic seems to be wrong. |
@dosu what do you think? |
Yes, you can modify the public static Image resolve(String id) {
String subid = XTFConfig.get("xtf." + id + ".subid");
Image image = Image.get(id + "." + subid);
if (image == null) {
image = Image.get(id);
if (image == null) {
throw new UnknownImageException("Unable to get image using " + id + " or " + subid);
}
}
String customReg = XTFConfig.get("xtf." + id + ".reg");
String customRegId = XTFConfig.get("xtf." + id + ".regid");
String customUser = XTFConfig.get("xtf." + id + ".user");
String customTag = XTFConfig.get("xtf." + id + ".tag");
String reg = customRegId != null ? XTFConfig.get("xtf.registry." + customRegId) : customReg;
reg = reg != null ? reg : image.getRegistry();
String user = customUser != null ? customUser : image.getUser();
String tag = customTag != null ? customTag : image.getTag();
return new Image(reg, user, image.getRepo(), tag);
} This modification ensures that the method first attempts to resolve the image using the subid and only falls back to the default image if the subid image is not found [1]. |
@dosu any objection with linked pull request? Do you think it address original issue? Are test correctly testing touched code? |
The linked pull request addresses the original issue by modifying the Regarding the tests, it is important to ensure that the tests cover scenarios involving both main id and subid configurations. Specifically, the tests should validate that:
Based on the information available, there are integration tests that validate the behavior of image resolution in different configurations, including cases with subid overrides. For example, the However, it is not explicitly mentioned whether these tests cover all the necessary scenarios for the |
@dosu could you generate test case which would test functionality of |
@dosu could you generate test for resolve method please? |
Certainly! Here is a test case to validate the functionality of the package cz.xtf.core.image;
import cz.xtf.core.config.XTFConfig;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import uk.org.webcompere.systemstubs.jupiter.SystemStub;
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
import uk.org.webcompere.systemstubs.properties.SystemProperties;
@ExtendWith(SystemStubsExtension.class)
public class ImageResolverTest {
@SystemStub
private SystemProperties systemProperties;
@Test
public void resolveWithSubidTest() {
systemProperties.set("xtf.eap.image", "registry.redhat.io/jboss-eap-8/eap8-openjdk17-builder-openshift-rhel8:latest");
systemProperties.set("xtf.eap.wildfly-openjdk17.image", "quay.io/wildfly/wildfly-s2i:latest-jdk17");
systemProperties.set("xtf.eap.subid", "wildfly-openjdk17");
Image image = Image.resolve("eap");
Assertions.assertEquals("quay.io", image.getRegistry());
Assertions.assertEquals("wildfly", image.getUser());
Assertions.assertEquals("wildfly-s2i", image.getRepo());
Assertions.assertEquals("latest-jdk17", image.getTag());
}
@Test
public void resolveWithoutSubidTest() {
systemProperties.set("xtf.eap.image", "registry.redhat.io/jboss-eap-8/eap8-openjdk17-builder-openshift-rhel8:latest");
systemProperties.set("xtf.eap.subid", "wildfly-openjdk17");
Image image = Image.resolve("eap");
Assertions.assertEquals("registry.redhat.io", image.getRegistry());
Assertions.assertEquals("jboss-eap-8", image.getUser());
Assertions.assertEquals("eap8-openjdk17-builder-openshift-rhel8", image.getRepo());
Assertions.assertEquals("latest", image.getTag());
}
@Test
public void resolveWithCustomRegistryTest() {
systemProperties.set("xtf.eap.image", "registry.redhat.io/jboss-eap-8/eap8-openjdk17-builder-openshift-rhel8:latest");
systemProperties.set("xtf.eap.subid", "wildfly-openjdk17");
systemProperties.set("xtf.eap.reg", "custom.registry.io");
Image image = Image.resolve("eap");
Assertions.assertEquals("custom.registry.io", image.getRegistry());
Assertions.assertEquals("jboss-eap-8", image.getUser());
Assertions.assertEquals("eap8-openjdk17-builder-openshift-rhel8", image.getRepo());
Assertions.assertEquals("latest", image.getTag());
}
@Test
public void resolveWithCustomUserTest() {
systemProperties.set("xtf.eap.image", "registry.redhat.io/jboss-eap-8/eap8-openjdk17-builder-openshift-rhel8:latest");
systemProperties.set("xtf.eap.subid", "wildfly-openjdk17");
systemProperties.set("xtf.eap.user", "customuser");
Image image = Image.resolve("eap");
Assertions.assertEquals("registry.redhat.io", image.getRegistry());
Assertions.assertEquals("customuser", image.getUser());
Assertions.assertEquals("eap8-openjdk17-builder-openshift-rhel8", image.getRepo());
Assertions.assertEquals("latest", image.getTag());
}
@Test
public void resolveWithCustomTagTest() {
systemProperties.set("xtf.eap.image", "registry.redhat.io/jboss-eap-8/eap8-openjdk17-builder-openshift-rhel8:latest");
systemProperties.set("xtf.eap.subid", "wildfly-openjdk17");
systemProperties.set("xtf.eap.tag", "customtag");
Image image = Image.resolve("eap");
Assertions.assertEquals("registry.redhat.io", image.getRegistry());
Assertions.assertEquals("jboss-eap-8", image.getUser());
Assertions.assertEquals("eap8-openjdk17-builder-openshift-rhel8", image.getRepo());
Assertions.assertEquals("customtag", image.getTag());
}
@Test
public void resolveImageNotFoundTest() {
systemProperties.set("xtf.eap.subid", "wildfly-openjdk17");
Assertions.assertThrows(UnknownImageException.class, () -> Image.resolve("eap"));
}
} This test class covers various scenarios for the
These tests ensure that the |
@mnovak1 Can you have a look ^ if there is something to incorporate from those proposals? :) |
I have this configuration in our testsuite
Idea is to have default image for products and override wildfly image for specific value. Unfortunatelly it does not behave like that and value is not overriden.
I can workaround by specifying image in each subid section. But could image behave similar as all other properties?
I think solution can be simple as switching order of code here
xtf/core/src/main/java/cz/xtf/core/image/Image.java
Lines 21 to 28 in 1daa976
eap.wildfly-openjdk17
and once it is not there default toeap
The text was updated successfully, but these errors were encountered: