Search in sources :

Example 46 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class FactsTests method testFactsUpdateWhenNotRegistered.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36613", "RHEL7-51423" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager: facts --update (when not registered)", groups = { "Tier2Tests", "blockedByBug-654429" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testFactsUpdateWhenNotRegistered() {
    // make sure we are not registered
    clienttasks.unregister(null, null, null, null);
    log.info("Assert that one must be registered to update the facts...");
    for (Boolean list : new Boolean[] { true, false }) {
        SSHCommandResult result = clienttasks.facts_(list, true, null, null, null, null);
        if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
            // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
            Assert.assertEquals(result.getStderr().trim(), clienttasks.msg_ConsumerNotRegistered, "stderr indicates that one must be registered to update the facts.");
        } else {
            Assert.assertEquals(result.getStdout().trim(), clienttasks.msg_ConsumerNotRegistered, "stdout indicates that one must be registered to update the facts.");
        }
    }
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 47 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class FactsTests method testMalformedCustomFacts.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36615", "RHEL7-51425" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager: subscription-manager should handle malformed custom facts with grace", groups = { "Tier2Tests", "MalformedCustomFacts_Test", "blockedByBug-966747", "blockedByBug-1112326", "blockedByBug-1435771" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testMalformedCustomFacts() {
    File malformedFactsFile = new File(clienttasks.factsDir + File.separatorChar + malformedFactsFilename);
    // mark the rhsm.log file
    String logMarker = System.currentTimeMillis() + " Testing MalformedCustomFacts_Test...";
    RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, logMarker);
    // create malformed facts
    Map<String, String> customFactsMap = new HashMap<String, String>();
    customFactsMap.put("malformed_fact", "value\" is \"misquoted");
    clienttasks.createFactsFileWithOverridingValues(malformedFactsFilename, customFactsMap);
    log.info("Here is the contents of our malformed custom facts file...");
    client.runCommandAndWait("cat " + malformedFactsFile);
    // attempt to register
    SSHCommandResult result = clienttasks.register(/*_*/
    sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, null, null, null, null, null);
    /* No need to assert results because the register task will assert that the results are successful despite the malformed facts
		// assert results
		Assert.assertEquals(result.getExitCode(),Integer.valueOf(0),"Exitcode from an attempt to register with malformed facts file '"+malformedFactsFile+"'.");
		Assert.assertEquals(result.getStdout(),"FIXME Need expected stdout message after bug 966747 is fixed","Stdout from an attempt to register with malformed facts file '"+malformedFactsFile+"'.");
		Assert.assertEquals(result.getStderr(),"FIXME Need expected stderr message after bug 966747 is fixed","Stdout from an attempt to register with malformed facts file '"+malformedFactsFile+"'.");
		*/
    // get the tail of the marked rhsm.log file
    String logTail = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, logMarker, null).trim();
    // assert a failure to load custom facts is logged
    // 2013-06-07 13:31:08,916 [WARNING]  @facts.py:125 - Unable to load custom facts file: /etc/rhsm/facts/malformed.facts
    String expectedLogMessage = "Unable to load custom facts file: " + malformedFactsFile;
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.19.3-1")) {
        // commit 4b7a8d39888de09bbd98ad44807485635eece14d Bug 1435771: Fix UnboundLocalError during custom facts collection
        // 2017-05-11 13:06:20,836 [INFO] subscription-manager:24583:MainThread @custom.py:85 - Loading custom facts from: /etc/rhsm/facts/malformed.facts
        // 2017-05-11 13:06:20,837 [WARNING] subscription-manager:24583:MainThread @custom.py:40 - Unable to load custom facts file.
        expectedLogMessage = "Loading custom facts from: " + malformedFactsFile;
        Assert.assertTrue(logTail.contains(expectedLogMessage), "The '" + clienttasks.rhsmLogFile + "' reports expected log message '" + expectedLogMessage + "'.");
        expectedLogMessage = "Unable to load custom facts file.";
    }
    Assert.assertTrue(logTail.contains(expectedLogMessage), "The '" + clienttasks.rhsmLogFile + "' reports expected log message '" + expectedLogMessage + "'.");
}
Also used : HashMap(java.util.HashMap) SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 48 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class FactsTests method testFactCheckRhelDistribution.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36610", "RHEL7-59318" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager: facts and rules: fact check RHEL distribution", groups = { "Tier2Tests", "blockedByBug-666540" }, dependsOnGroups = {}, enabled = true)
@ImplementsNitrateTest(caseId = 56329)
public void testFactCheckRhelDistribution() {
    // skip if client1 and client2 are not a Server and Workstation distributions
    SSHCommandRunner workClient = null, servClient = null;
    SubscriptionManagerTasks workClientTasks = null, servClientTasks = null;
    if (client1 != null && client1tasks.getRedhatRelease().startsWith("Red Hat Enterprise Linux Workstation")) {
        workClient = client1;
        workClientTasks = client1tasks;
    }
    if (client2 != null && client2tasks.getRedhatRelease().startsWith("Red Hat Enterprise Linux Workstation")) {
        workClient = client2;
        workClientTasks = client2tasks;
    }
    if (client1 != null && client1tasks.getRedhatRelease().startsWith("Red Hat Enterprise Linux Server")) {
        servClient = client1;
        servClientTasks = client1tasks;
    }
    if (client2 != null && client2tasks.getRedhatRelease().startsWith("Red Hat Enterprise Linux Server")) {
        servClient = client2;
        servClientTasks = client2tasks;
    }
    if (workClient == null || servClient == null) {
        throw new SkipException("This test requires a RHEL Workstation client and a RHEL Server client.");
    }
    // start with fresh registrations using the same clientusername user
    workClientTasks.unregister(null, null, null, null);
    servClientTasks.unregister(null, null, null, null);
    workClientTasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    servClientTasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, null, false, null, null, null, null);
    // get all the pools available to each client
    List<SubscriptionPool> workClientPools = workClientTasks.getCurrentlyAvailableSubscriptionPools();
    List<SubscriptionPool> servClientPools = servClientTasks.getCurrentlyAvailableSubscriptionPools();
    log.info("Verifying that the pools available to the Workstation consumer are not identitcal to those available to the Server consumer...");
    if (!(!workClientPools.containsAll(servClientPools) || !servClientPools.containsAll(workClientPools))) {
        // TODO This testcase needs more work.  Running on different variants of RHEL alone is not enough to assert that the available pools are different.  In fact, then should be the same if the subscriptions are all set with a variant attribute of ALL
        throw new SkipException("The info message above is not accurate... The assertion that the pools available to a Workstation consumer versus a Server consumer is applicable ONLY when the org's subscriptions includes a variant aware subscription.  In fact, if the org's subscriptions are all set with a variant attribute of ALL, then the available pools should be identical.  This automated test needs some work.");
    }
    Assert.assertTrue(!workClientPools.containsAll(servClientPools) || !servClientPools.containsAll(workClientPools), "Because the facts of a system client running RHEL Workstation versus RHEL Server should be different, the available subscription pools to these two systems should not be the same.");
// FIXME TODO Verify with development that these are valid asserts
// log.info("Verifying that the pools available to the Workstation consumer do not contain Server in the ProductName...");
// log.info("Verifying that the pools available to the Server consumer do not contain Workstation in the ProductName...");
}
Also used : SSHCommandRunner(com.redhat.qe.tools.SSHCommandRunner) SubscriptionManagerTasks(rhsm.cli.tasks.SubscriptionManagerTasks) SkipException(org.testng.SkipException) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 49 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class FactsTests method testEmptyCustomFacts.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36608", "RHEL7-51420" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager: subscription-manager should handle empty custom facts with grace", groups = { "Tier2Tests", "EmptyCustomFacts_Test", "blockedByBug-966747", "blockedByBug-1112326", "blockedByBug-1435771" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEmptyCustomFacts() {
    File emptyFactsFile = new File(clienttasks.factsDir + File.separatorChar + emptyFactsFilename);
    // create empty facts
    client.runCommandAndWait("rm -f " + emptyFactsFile + " && touch " + emptyFactsFile);
    Assert.assertTrue(RemoteFileTasks.testExists(client, emptyFactsFile.getPath()), "The empty facts file should exist.");
    // mark the rhsm.log file
    String logMarker = System.currentTimeMillis() + " Testing EmptyCustomFacts_Test...";
    RemoteFileTasks.markFile(client, clienttasks.rhsmLogFile, logMarker);
    // attempt to register
    SSHCommandResult result = clienttasks.register(/*_*/
    sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, Boolean.TRUE, null, null, null, null, null);
    /* No need to assert results because the register task above will assert that the results are successful despite the empty facts
		// assert results
		Assert.assertEquals(result.getExitCode(),Integer.valueOf(0),"Exitcode from an attempt to register with an empty facts file '"+emptyFactsFile+"'.");
		Assert.assertEquals(result.getStdout(),"FIXME Need expected stdout message after bug 966747 is fixed","Stdout from an attempt to register with an empty facts file '"+emptyFactsFile+"'.");
		Assert.assertEquals(result.getStderr(),"FIXME Need expected stderr message after bug 966747 is fixed","Stdout from an attempt to register with an empty facts file '"+emptyFactsFile+"'.");
		*/
    // get the tail of the marked rhsm.log file
    String logTail = RemoteFileTasks.getTailFromMarkedFile(client, clienttasks.rhsmLogFile, logMarker, null).trim();
    // assert a failure to load custom facts is logged
    // 2013-06-07 13:31:08,916 [WARNING]  @facts.py:125 - Unable to load custom facts file: /etc/rhsm/facts/empty.facts
    String expectedLogMessage = "Unable to load custom facts file: " + emptyFactsFile;
    if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.19.3-1")) {
        // commit 4b7a8d39888de09bbd98ad44807485635eece14d Bug 1435771: Fix UnboundLocalError during custom facts collection
        // 2017-05-11 13:06:20,836 [INFO] subscription-manager:24583:MainThread @custom.py:85 - Loading custom facts from: /etc/rhsm/facts/empty.facts
        // 2017-05-11 13:06:20,837 [WARNING] subscription-manager:24583:MainThread @custom.py:40 - Unable to load custom facts file.
        expectedLogMessage = "Loading custom facts from: " + emptyFactsFile;
        Assert.assertTrue(logTail.contains(expectedLogMessage), "The '" + clienttasks.rhsmLogFile + "' reports expected log message '" + expectedLogMessage + "'.");
        expectedLogMessage = "Unable to load custom facts file.";
    } else
        Assert.assertTrue(logTail.contains(expectedLogMessage), "The '" + clienttasks.rhsmLogFile + "' reports expected log message '" + expectedLogMessage + "'.");
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) File(java.io.File) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 50 with ImplementsNitrateTest

use of com.redhat.qe.auto.tcms.ImplementsNitrateTest in project rhsm-qe by RedHatQE.

the class FactsTests method testBypassRulesDueToTypeAndCapabilities.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36607", "RHEL7-51419" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "subscription-manager: facts and rules: bypass rules due to candlepin type and capabilities", groups = { "Tier2Tests", "blockedByBug-641027", "BypassRulesDueToTypeAndCapabilities_Test" }, dependsOnGroups = {}, enabled = true)
@ImplementsNitrateTest(caseId = 56331)
public void testBypassRulesDueToTypeAndCapabilities() throws Exception {
    // this list will grow in time as candlepins are programmed to handle more subscription types (I got this list from the dev team)
    // List<String> allCapabilities = Arrays.asList(new String[]{"cores", "ram", "instance_multiplier", "derived_product", "cert_v3"});
    // we can actually get this list from the candlepin API call to /status
    List<String> allCapabilities = servertasks.statusCapabilities;
    // randomly reorder this list
    allCapabilities = getRandomSubsetOfList(allCapabilities, allCapabilities.size());
    // set minimal facts
    // these facts will prevent cores, sockets, and ram from interfering with compliance based on the system arch
    Map<String, String> factsMap = new HashMap<String, String>();
    factsMap.put("cpu.cpu_socket(s)", "1");
    factsMap.put("cpu.core(s)_per_socket", "1");
    factsMap.put("memory.memtotal", "1");
    clienttasks.createFactsFileWithOverridingValues(factsMap);
    // register (as type candlepin)
    String consumerId;
    if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", /*TODO CHANGE TO ">" after candlepin 2.1.2-1 is tagged*/
    "2.1.1-1")) {
        // candlepin commit 739b51a0d196d9d3153320961af693a24c0b826f Bug 1455361: Disallow candlepin consumers to be registered via Subscription Manager
        clienttasks.unregister(null, null, null, null);
        clienttasks.registerCandlepinConsumer(sm_clientUsername, sm_clientPassword, sm_clientOrg, sm_serverUrl, "candlepin");
        consumerId = clienttasks.getCurrentConsumerId();
    } else {
        consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.candlepin, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null));
    }
    // by default, this consumer starts out with no capabilities
    JSONObject jsonConsumer = (JSONObject) new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/consumers/" + consumerId));
    JSONArray jsonCapabilities = jsonConsumer.getJSONArray("capabilities");
    Assert.assertTrue(jsonCapabilities.length() == 0, "By default, a freshly registered consumer of type=candlepin has no capabilities.");
    // get the initial list of available pools and all available pools
    List<SubscriptionPool> initialAvailablePools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    List<SubscriptionPool> initialAllAvailablePools = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
    Assert.assertTrue(initialAllAvailablePools.containsAll(initialAvailablePools), "The pools --available to a consumer of type=candlepin is a subset of --all --available pools.");
    Assert.assertFalse(initialAvailablePools.containsAll(initialAllAvailablePools), "Without any capabilities, --all --available pools contains addtional pools that are not --available for consumption by a consumer of type=candlepin (Assumes some subscriptions with attributes " + allCapabilities + " are available to org " + sm_clientOrg);
    // incrementally give the candlepin consumer more capabilities (starting with none)
    List<String> currentCapabilities = new ArrayList<String>();
    for (int i = 0; i <= allCapabilities.size(); i++) {
        // get the current list of available pools and all available pools
        List<SubscriptionPool> currentAvailablePools = clienttasks.getCurrentlyAvailableSubscriptionPools();
        List<SubscriptionPool> currentAllAvailablePools = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
        // loop through the unavailable pools and assert that the subscription's product attribute contains a capability that is absent from this consumer
        for (SubscriptionPool pool : currentAllAvailablePools) {
            if (!currentAvailablePools.contains(pool)) {
                SubscriptionPool unavailablePool = pool;
                // the reason this pool from allAvailablePools should not be available is because it must have a product attribute that is not among the consumer's current capabilities.  Let's test it...
                boolean unavailablePoolHasAnUnavailableCapability = false;
                for (String capability : allCapabilities) {
                    // assume the capability is a an attribute of the pool product
                    if (!currentCapabilities.contains(capability)) {
                        if (CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, capability) != null) {
                            Assert.assertTrue(true, "Subscription Pool '" + pool.subscriptionName + "' is not available to a consumer of type=candlepin with capabilities " + currentCapabilities + " because this pool's product attributes includes capability '" + capability + "' and therefore requires that the candlepin consumer also possess the capability '" + capability + "'.");
                            unavailablePoolHasAnUnavailableCapability = true;
                        }
                    }
                    // handle "derived_product" capability a little differently
                    if (!currentCapabilities.contains(capability) && capability.equals("derived_product")) {
                        if (CandlepinTasks.isPoolADataCenter(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId)) {
                            Assert.assertTrue(true, "Subscription Pool '" + pool.subscriptionName + "' is not available to a consumer of type=candlepin with capabilities " + currentCapabilities + " because this pool will derive subpools for a different product and requires that this consumer of type=candlepin to possess the capability '" + capability + "'.");
                            unavailablePoolHasAnUnavailableCapability = true;
                        }
                    }
                // TODO we probably need to handle "cert_v3" capability a little differently
                }
                Assert.assertTrue(unavailablePoolHasAnUnavailableCapability, "At least one of the capability attributes present in Subscription Pool '" + pool.subscriptionName + "' is not among the current capabilities " + currentCapabilities + " of this consumer of type=candlepin. (This is why this pool appears in list --all --available and is not just list --available.)");
            }
        }
        // break out of the loop when we have tested all capabilities
        if (currentCapabilities.containsAll(allCapabilities))
            break;
        // update the consumer with another capability
        currentCapabilities.add(allCapabilities.get(i));
        CandlepinTasks.setCapabilitiesForConsumer(sm_clientUsername, sm_clientPassword, sm_serverUrl, consumerId, currentCapabilities);
    }
    // now that the consumer has all capabilities, list --available and list --all --available should be identical for a candlepin consumer
    log.info("Now that this candlepin consumer supports all the available capabilities " + allCapabilities + ", the list of --available pools should be identical to --all --available pools regardless of fact rules.");
    List<SubscriptionPool> finalAvailablePools = clienttasks.getCurrentlyAvailableSubscriptionPools();
    List<SubscriptionPool> finalAllAvailablePools = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
    Assert.assertTrue(finalAvailablePools.containsAll(finalAllAvailablePools) && finalAllAvailablePools.containsAll(finalAvailablePools), "The pools --available to a consumer of type=candlepin with all capabilities " + allCapabilities + " is identical to --all --available pools.");
    Assert.assertTrue(finalAvailablePools.containsAll(initialAllAvailablePools) && initialAllAvailablePools.containsAll(finalAvailablePools), "The pools --available to a consumer of type=candlepin with all capabilities " + allCapabilities + " is identical to --all --available pools when the same consumer possessed no capabilities.");
    // now let's compare the type=candlepin's finalAllAvailablePools to a type=system's listAllAvailablePools
    // the difference in the list should be generated subpools and DOMAIN subscriptions
    log.info("Now let's register a consumer of type=system and compare its list --all --available to the type=candlepin consumer's list --all --available.");
    // register (as type system)
    consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, ConsumerType.system, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null));
    List<SubscriptionPool> allAvailablePoolsToSystem = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
    List<SubscriptionPool> allAvailablePoolsToCandlepin = finalAllAvailablePools;
    for (SubscriptionPool pool : allAvailablePoolsToSystem) {
        if (!allAvailablePoolsToCandlepin.contains(pool)) {
            log.warning("Pool '" + pool.subscriptionName + "' is in consumer type=system list --all --available, but NOT in consumer type=candlepin list --all --available.");
            Assert.assertTrue(CandlepinTasks.isPoolDerived(sm_clientUsername, sm_clientPassword, pool.poolId, sm_serverUrl), "Pool '" + pool.subscriptionName + "' is in consumer type=system list --all --available, but NOT in consumer type=candlepin list --all --available because this is a derived pool.");
        }
    }
    for (SubscriptionPool pool : allAvailablePoolsToCandlepin) {
        if (!allAvailablePoolsToSystem.contains(pool)) {
            log.warning("Pool '" + pool.subscriptionName + "' is in candlepin list --all --available, but NOT in system list --all --available.");
            String requiresConsumerType = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, pool.poolId, "requires_consumer_type");
            Assert.assertTrue(requiresConsumerType != null && !requiresConsumerType.equals(ConsumerType.system), "Pool '" + pool.subscriptionName + "' is in candlepin list --all --available, but NOT in system list --all --available because this pool's product requires_consumer_type '" + requiresConsumerType + "'.");
        }
    }
}
Also used : JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONArray(org.json.JSONArray) ArrayList(java.util.ArrayList) SubscriptionPool(rhsm.data.SubscriptionPool) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Aggregations

ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)267 Test (org.testng.annotations.Test)267 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)244 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)146 SkipException (org.testng.SkipException)125 SubscriptionPool (rhsm.data.SubscriptionPool)71 ArrayList (java.util.ArrayList)62 BigInteger (java.math.BigInteger)53 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)42 ProductSubscription (rhsm.data.ProductSubscription)42 File (java.io.File)36 JSONObject (org.json.JSONObject)33 EntitlementCert (rhsm.data.EntitlementCert)32 ProductCert (rhsm.data.ProductCert)32 InstalledProduct (rhsm.data.InstalledProduct)15 ConsumerCert (rhsm.data.ConsumerCert)14 HashMap (java.util.HashMap)11 Calendar (java.util.Calendar)10 List (java.util.List)10 JSONArray (org.json.JSONArray)8