From f4ae1d913db41d08aa511ebeafa7e7f5ebbc9470 Mon Sep 17 00:00:00 2001 From: Kevin Flaherty Date: Mon, 16 Oct 2023 16:14:30 -0400 Subject: [PATCH] Check for available EngId before using arch --- .../subscriptions/tally/facts/FactNormalizer.java | 4 +++- .../subscriptions/tally/facts/FactNormalizerTest.java | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/candlepin/subscriptions/tally/facts/FactNormalizer.java b/src/main/java/org/candlepin/subscriptions/tally/facts/FactNormalizer.java index 5daa3a7901..7d5674bb3b 100644 --- a/src/main/java/org/candlepin/subscriptions/tally/facts/FactNormalizer.java +++ b/src/main/java/org/candlepin/subscriptions/tally/facts/FactNormalizer.java @@ -26,6 +26,7 @@ import java.util.Collection; import java.util.Objects; import java.util.stream.Collectors; +import org.apache.commons.collections4.CollectionUtils; import org.candlepin.subscriptions.ApplicationProperties; import org.candlepin.subscriptions.db.model.HardwareMeasurementType; import org.candlepin.subscriptions.db.model.HostHardwareType; @@ -329,7 +330,8 @@ private void handleSla( private void normalizeQpcFacts(NormalizedFacts normalizedFacts, InventoryHostFacts hostFacts) { // Check if this is a RHEL host and set product. if (hostFacts.getQpcProducts() != null && hostFacts.getQpcProducts().contains("RHEL")) { - if (hostFacts.getSystemProfileArch() != null) { + if (hostFacts.getSystemProfileArch() != null + && CollectionUtils.isEmpty(hostFacts.getQpcProductIds())) { switch (hostFacts.getSystemProfileArch()) { case "x86_64", "i686", "i386": normalizedFacts.addProduct("RHEL for x86"); diff --git a/src/test/java/org/candlepin/subscriptions/tally/facts/FactNormalizerTest.java b/src/test/java/org/candlepin/subscriptions/tally/facts/FactNormalizerTest.java index ed3ec9fe65..5665cffdc3 100644 --- a/src/test/java/org/candlepin/subscriptions/tally/facts/FactNormalizerTest.java +++ b/src/test/java/org/candlepin/subscriptions/tally/facts/FactNormalizerTest.java @@ -686,6 +686,14 @@ void testQpcSystemArchSetRhelForIbmPower() { assertThat(normalized.getProducts(), Matchers.hasItem("RHEL for IBM Power")); } + @Test + void testQpcProductIdFromEngId() { + var host = createQpcHost("RHEL", "Test", clock.now()); + host.setQpcProductIds("69"); + NormalizedFacts normalized = normalizer.normalize(host, hypervisorData()); + assertThat(normalized.getProducts(), Matchers.hasItem("RHEL for x86")); + } + private void assertClassification( NormalizedFacts check, boolean isHypervisor, boolean isHypervisorUnknown, boolean isVirtual) { assertEquals(isHypervisor, check.isHypervisor());