def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 self.__class__.__name__)
     try:
         try:
             username = RHSMConstants().get_constant("username")
             password = RHSMConstants().get_constant("password")
             self.open_subscription_manager()
             self.register_and_autosubscribe_in_gui(username, password)
             self.click_view_system_facts_menu()
             self.click_facts_view_tree("system")
             if self.check_org_displayed_in_facts(username, password):
                 logger.info(
                     "It's successful to check orgs displayed in system facts in GUI "
                 )
             else:
                 raise FailException(
                     "Test Faild - Failed to check orgs displayed in system facts in GUI"
                 )
             if self.check_system_uuid_displayed_in_facts():
                 logger.info(
                     "It's successful to check system_uuid displayed in system facts in GUI "
                 )
             else:
                 raise FailException(
                     "Test Faild - Failed to check system_uuid displayed in system facts in GUI"
                 )
             self.assert_(True, case_name)
         except Exception, e:
             logger.error("Test Failed - ERROR Message:" + str(e))
             self.assert_(False, case_name)
     finally:
         self.capture_image(case_name)
         self.restore_gui_environment()
         logger.info("========== End of Running Test Case: %s ==========" %
                     case_name)
コード例 #2
0
 def check_sku_in_consumed_subscriptions(self):
     sku = None
     cmd = "subscription-manager list --consumed | grep 'SKU'"
     (ret,
      output) = self.runcmd(cmd,
                            "check sku in the list consumed subscriptions")
     print "output: \n", output[0]
     if ret == 0:
         sku = output.split(":")[1].strip()
         return sku
     else:
         return sku
         raise FailException(
             "Test Failed - error happened when check sku in the list consumed subscriptions"
         )
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         # modify values of configuration item for the system
         # cmd="subscription-manager config --server.insecure=%s --server.proxy_port=%s --rhsm.insecure=%s --rhsm.proxy_port=%s --rhsmcertd.insecure=%s --rhsmcertd.proxy_port=%s"%(modinsecure, modproxyport, modinsecure, modproxyport, modinsecure, modproxyport)
         cmd = "subscription-manager config --server.insecure=%s --server.proxy_port=%s" % (
             self.modinsecure, self.modproxyport)
         (ret, output) = self.runcmd(cmd, "modify values of config items")
         if (self.is_configuration_modified()):
             logger.info(
                 "Default values of configuration items(insecure and proxy_port) have been modified."
             )
             # remove values of configuration item for the system
             # cmd="subscription-manager config --remove server.insecure --remove server.proxy_port --remove rhsm.insecure --remove rhsm.proxy_port --remove rhsmcertd.insecure --remove rhsmcertd.proxy_port"
             cmd = "subscription-manager config --remove server.insecure --remove server.proxy_port"
             (ret, output) = self.runcmd(cmd,
                                         "remove values of config items")
             if ret == 0 and "You have removed the value for section" in output and "The default value for" in output:
                 if self.is_configuration_removed():
                     logger.info(
                         "It's successful to remove current values of configuration item for the system."
                     )
                 else:
                     raise FailException(
                         "Test Failed - remove current values of configuration item are not correct."
                     )
             else:
                 raise FailException(
                     "Failed to remove current values of configuration item."
                 )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
コード例 #4
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         username = RHSMConstants().get_constant("username")
         password = RHSMConstants().get_constant("password")
         self.sub_register(username, password)
         autosubprod = RHSMConstants().get_constant("autosubprod")
         self.sub_autosubscribe(autosubprod)
         productrepo = RHSMConstants().get_constant("productrepo")
         cmd = "subscription-manager repos --list | grep %s" % productrepo
         (ret, output) = self.runcmd(cmd, "check the repo %s" % productrepo)
         if ret == 0 and productrepo in output:
             logger.info(
                 "It's successful to check the repo %s which is available."
                 % productrepo)
             # enable the repo in list
             cmd = "subscription-manager repos --enable=%s" % productrepo
             (ret, output) = self.runcmd(cmd,
                                         "enable the repo %s" % productrepo)
             if ret == 0 and "Repository '%s' is enabled for this system." % productrepo in output:
                 logger.info("It's successful to disable the repo %s." %
                             productrepo)
             else:
                 raise FailException(
                     "Test Failed - Failed to enable the repo %s." %
                     productrepo)
         else:
             raise FailException(
                 "Test Failed - Fail to check the repo %s which should be available."
                 % productrepo)
         self.assert_(True, case_name)
     except Exception, e:
         logger.error(str(e))
         self.assert_(False, case_name)
コード例 #5
0
 def is_redhatrepo_exist(self, expectbool):
     # check redhat.repo file exist or not
     cmd = "ls /etc/yum.repos.d/"
     (ret, output) = self.runcmd(cmd, "check redhat.repo exist")
     if not expectbool:
         existed = output.count("bak") == output.count("redhat.repo")
     else:
         existed = not (output.count("bak") == output.count("redhat.repo"))
     if ret == 0 and existed:
         logger.info(
             "It's successful to check redhat.repo file exist: %s." %
             expectbool)
     else:
         raise FailException(
             "Test Failed - Failed to delete redhat.repo file.")
コード例 #6
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % case_name)
     try:
         # use identity command to show where system is registerd to
         cmd = "subscription-manager identity"
         (ret, output) = self.runcmd(cmd, "running identity command")
         if ret != 0 and ("This system is not yet registered. Try 'subscription-manager register --help' for more information." in output):
             logger.info("It's successful to check the output of identity command when the machine is not registered.")
         else:
             raise FailException("Test Failed - Failed to check the output of identity command when the machine is not registered.")
         self.assert_(True, case_name)
     except Exception, e:
         logger.error(str(e))
         self.assert_(False, case_name)
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % case_name)
     try:
         username = RHSMConstants().get_constant("username")
         password = RHSMConstants().get_constant("password")
         self.sub_register(username, password)
         autosubprod = RHSMConstants().get_constant("autosubprod")
         self.sub_autosubscribe(autosubprod)
         # set healfrequency = 1
         self.sub_set_healfrequency(1)
         # 1. Unsubscribe the subscription
         self.sub_unsubscribe()
         # 2. refresh the local data
         cmd = 'subscription-manager refresh'
         (ret, output) = self.runcmd(cmd, "reflash")
         if ret == 0  and 'All local data refreshed' in output:    
             logger.info("It's successful to do refresh local data")
         else:
             raise FailException("Test Failed - Failed to do refresh.")
         # 3. Restart the rhsmcertd service
         cmd = 'service rhsmcertd restart'
         self.runcmd(cmd, "restart rhsmcertd")
         # 4. List the consumed
         cmd = 'subscription-manager refresh'
         (ret, output) = self.runcmd(cmd, "refresh rhsmcertd")
         logger.info("Waiting 90 seconds for rhsmcertd service to take effect...")
         time.sleep(90)
         if self.sub_isconsumed(autosubprod):
             logger.info("It's successful to list consumed.")
         else:
             raise FailException("Test Failed - Failed to list consumed.")
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
コード例 #8
0
 def list_enddate(self, output):
     datalines = output.splitlines()
     segs = []
     timeline = ""
     for line in datalines:
         if "Ends:" in line:
             tmpline = line
             segs.append(tmpline)
     for aa in segs:
         endtimeitem = aa.split(":")[0].replace(' ', '')
         endtimevalue = aa.split(":")[1].strip()
         if compare_time(endtimevalue) == 0:
             logger.info("It's correct to list this subscription.")
         else:
             raise FailException("The subscription shouldn't be list")
    def test_run(self):
        case_name = self.__class__.__name__
        logger.info("========== Begin of Running Test Case %s ==========" %
                    case_name)
        try:
            username = RHSMConstants().get_constant("username")
            password = RHSMConstants().get_constant("password")
            self.sub_register(username, password)
            # list availalbe entitlement pools
            productid = RHSMConstants().get_constant("productid")
            availpoollist = self.sub_listavailpools(productid)

            # get an available entitlement pool to subscribe with random.sample
            availpool = random.sample(availpoollist, 1)[0]
            if "SubscriptionName" in availpool:
                poolid = availpool["PoolID"]
                subscriptionname = availpool["SubscriptionName"]
                productid = availpool["SKU"]

                # subscribe the product with poolid
                cmd = "subscription-manager subscribe --pool=%s" % poolid
                (ret, output) = self.runcmd(cmd, "subscribe with poolid")
                expectout = "Successfully consumed a subscription for: %s" % subscriptionname
                # expectoutnew is for rhel new feature output
                expectoutnew = "Successfully attached a subscription for: %s" % subscriptionname
                if 0 == ret and ((expectout in output) or
                                 (expectoutnew in output)):
                    logger.info("It's successful to do subscribe to a pool")
                else:
                    logger.error(
                        "Test Failed - error happened when do subscribe to a pool"
                    )
            # get the number of entitlement cert
            cmd = "ls /etc/pki/entitlement | grep -v key.pem | wc -l"
            (ret, number) = self.runcmd(cmd,
                                        "get the number of entitlement cert")
            if (ret == 0) and (number.strip('\n') == "1"):
                logger.info(
                    "It's successful to verify that only one entitlement certificate is produced for each subscription to an entitlement pool"
                )
            else:
                raise FailException(
                    "Test Failed - Failed to verify that only one entitlement certificate is produced for each subscription to an entitlement pool"
                )
            self.assert_(True, case_name)
        except Exception, e:
            logger.error("Test Failed - ERROR Message:" + str(e))
            self.assert_(False, case_name)
コード例 #10
0
 def check_autosub_result(self, autosubprod):
     cmd = "subscription-manager subscribe --auto"
     (ret, output) = self.runcmd(cmd, "check auto-subscribe result")
     if ret != 0:
         if "No Installed products on system. No need to attach subscriptions." in output:
             logger.info(
                 "It's successful to check no need to update subscription for RHEL5 system."
             )
         elif ("Product Name:" not in output) and (autosubprod
                                                   not in output):
             logger.info(
                 "It's successful to check no need to update subscription for RHEL6 system."
             )
     else:
         raise FailException(
             "Test Failed - check no need to update subscription.")
コード例 #11
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         # register to and auto-attach
         username = RHSMConstants().get_constant("username")
         password = RHSMConstants().get_constant("password")
         autosubprod = RHSMConstants().get_constant("autosubprod")
         self.register_and_autosubscribe(username, password, autosubprod)
         # get variables form ent_env
         repoid = RHSMConstants().get_constant("productrepo")
         pid = RHSMConstants().get_constant("pid")
         pkgtoinstall = RHSMConstants().get_constant("pkgtoinstall")
         # check repo exist
         if self.is_enabled_repo(repoid):
             # check package to be installed exist
             self.check_givenpkg_avail(repoid, pkgtoinstall)
             # install test-pkg
             self.install_givenpkg(pkgtoinstall)
         else:
             raise FailException(
                 "Test Failed - The product repoid is not exist.")
         # check the cert file exist.
         certfile = pid + ".pem"
         self.check_cert_file(certfile)
         # check productid cert
         self.sub_checkproductcert(pid)
         # uninstall test-pkg
         self.uninstall_givenpkg(pkgtoinstall)
         ####                    install the same package when system expired         ###
         # make the system expired
         self.set_system_date()
         # install test-pkg again
         self.install_givenpkg(pkgtoinstall)
         # restore the system time
         self.restore_system_time()
         ####                    install the same package when system expired         ###
         # unsubscribe all subscriptions
         self.sub_unsubscribe()
         # install test-pkg again
         self.install_givenpkg(pkgtoinstall)
         self.assert_(True, case_name)
     except Exception, e:
         logger.error(str(e))
         self.assert_(False, case_name)
コード例 #12
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % case_name)
     try:
         try:
             username = RHSMConstants().get_constant("username")
             password = RHSMConstants().get_constant("password")
             self.open_subscription_manager()
             self.register_in_gui(username, password)
             raise FailException("Not completed yet ......")
             self.assert_(True, case_name)
         except Exception, e:
             logger.error("Test Failed - ERROR Message:" + str(e))
             self.assert_(False, case_name)
     finally:
         self.capture_image(case_name)
         self.restore_gui_environment()
         logger.info("========== End of Running Test Case: %s ==========" % case_name)
 def uninstall_givenpkg(self, testpkg):
     cmd = "rpm -qa | grep %s" % (testpkg)
     (ret, output) = self.runcmd(cmd, "check package %s" % testpkg)
     if ret == 1:
         logger.info("There is no need to remove package")
     else:
         cmd = "yum remove -y %s" % (testpkg)
         (ret, output) = self.runcmd(cmd,
                                     "remove select package %s" % testpkg)
         if ret == 0 and "Complete!" in output and "Removed" in output:
             logger.info("The package %s is uninstalled successfully." %
                         (testpkg))
         elif ret == 0 and "No package %s available" % testpkg in output:
             logger.info("The package %s is not installed at all" %
                         (testpkg))
         else:
             raise FailException(
                 "Test Failed - The package %s is failed to uninstall." %
                 (testpkg))
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         cmd = "subscription-manager config --help | grep -A1 -- --proxy"
         (ret, output) = self.runcmd(cmd, "check proxy option")
         if ret != 0 and 'proxy' not in output:
             logger.info(
                 "It's successful to check config should NOT have proxy options"
             )
         else:
             raise FailException(
                 "Test Failed - Failed to check config should NOT have proxy options."
             )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 self.__class__.__name__)
     try:
         try:
             username = RHSMConstants().get_constant("username")
             password = RHSMConstants().get_constant("password")
             self.open_subscription_manager()
             self.register_in_gui(username, password)
             self.click_all_available_subscriptions_tab()
             self.click_filters_button()
             self.check_checkbox("filter-options-window",
                                 "match-installed-checkbox")
             self.uncheck_checkbox("filter-options-window",
                                   "match-system-checkbox")
             self.uncheck_checkbox("filter-options-window",
                                   "do-not-overlap-checkbox")
             self.click_filter_close_button()
             self.click_filters_button()
             if not (self.verifycheck_checkbox("filter-options-window",
                                               "match-system-checkbox")
                     and self.verifycheck_checkbox(
                         "filter-options-window", "do-not-overlap-checkbox")
                     and not self.verifycheck_checkbox(
                         "filter-options-window",
                         "match-installed-checkbox")):
                 logger.info(
                     "It's successful to check filter_options_persisted_in_session"
                 )
             else:
                 raise FailException(
                     "Test Faild - Failed to check filter_options_persisted_in_session"
                 )
             self.assert_(True, case_name)
         except Exception, e:
             logger.error("Test Failed - ERROR Message:" + str(e))
             self.assert_(False, case_name)
     finally:
         self.capture_image(case_name)
         self.restore_gui_environment()
         logger.info("========== End of Running Test Case: %s ==========" %
                     case_name)
コード例 #16
0
 def list_availalbe(self, direct):
     cmd_list = "subscription-manager list --available"
     (ret, output) = self.runcmd(cmd_list,
                                 "list the available subscriptions")
     if ret != 0:
         if (direct == 'mess1' and
             ("This system is not yet registered" in output)) or (
                 direct == 'mess2' and ("bad base64 decode" in output)):
             logger.info(
                 "It's successful to verify that no subscription is available with changed identity cert!"
             )
     elif direct == 'recover' and ret == 0:
         logger.info(
             "It's successful to verify that available subscription is listed with recovered identity cert!"
         )
     else:
         raise FailException(
             "Test Failed - error happened when list available subscriptions"
         )
コード例 #17
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % case_name)
     try:
         username = RHSMConstants().get_constant("username")
         password = RHSMConstants().get_constant("password")
         self.sub_register(username, password)
         autosubprod = RHSMConstants().get_constant("autosubprod")
         self.sub_autosubscribe(autosubprod)
         # run cmd unsubscribe --all
         cmd = "subscription-manager unsubscribe --all"
         (ret, output) = self.runcmd(cmd, "run cmd unsubscribe --all")
         expectoutput = "This machine has been unsubscribed from 1 subscriptions"
         expectoutputnew = "subscription removed from this system."
         expectoutput5101 = "subscription removed at the server."
         expectoutput5102 = "local certificate has been deleted."
         if 0 == ret and ((expectoutput5101 in output and expectoutput5102 in output) or (expectoutput in output or expectoutputnew in output)):
             firstresult = True
             print "True\n"
         else:
             firstresult = False
             print "False\n"
         # unsubscribe before subscribe
         cmd = "subscription-manager unsubscribe --all"
         (ret, output) = self.runcmd(cmd, "run cmd unsubscribe --all again")
         expectoutput = "This machine has been unsubscribed from 0 subscriptions"
         expectoutputnew = "0 subscriptions removed from this system."
         expectoutput510 = "subscriptions removed at the server."
         if 0 == ret and (expectoutput510 in output or expectoutput in output or expectoutputnew in output):
             secondresult = True
             print "True\n"
         else:
             secondresult = False
             print "False\n"
         if firstresult and secondresult:
             logger.info("It is successful to run cmd subscription-manager unsubscribe --all and check the output!")
         else:
             raise FailException("Test Faild - Failed to run cmd subscription-manager unsubscribe --all and check the output!")
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
コード例 #18
0
 def get_subscription_status(self):
     cmd = "subscription-manager list --consumed | grep Active"
     (ret, output) = self.runcmd(cmd, "get subscription status")
     if ret == 0:
         if "False" in output:
             logger.info(
                 "It's successful to get subscription status: the subscription is expired"
             )
             return "False"
         elif "True" in output:
             logger.info(
                 "It's successful to get subscription status: the subscription is not expired"
             )
             return "True"
         else:
             logger.info("nonsense status ")
             return "None"
     else:
         raise FailException(
             "Test Failed - Failed to get subscription status.")
コード例 #19
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % self.__class__.__name__)
     try:
         try:
             self.open_subscription_manager()
             self.click_about_menu()
             if self.check_object_exist("about-subscription-manager-dialog", "about-subscription-manager-dialog"):
                 logger.info("It's successful to check open_subscription_manager_about_from_menu.")
             else:
                 raise FailException("Test Faild - Failed to check open_subscription_manager_about_from_menu!")
             self.assert_(True, case_name)
         except Exception, e:
             logger.error("Test Failed - ERROR Message:" + str(e))
             self.assert_(False, case_name)
     finally:
         self.capture_image(case_name)
         self.close_window("about-subscription-manager-dialog")
         self.restore_gui_environment()
         logger.info("========== End of Running Test Case: %s ==========" % case_name)
コード例 #20
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % case_name)
     try:
         username = RHSMConstants().get_constant("username")
         password = RHSMConstants().get_constant("password")
         self.sub_register(username, password)
         # get service_level
         service_level = RHSMConstants().get_constant("servicelevel")
         # auto subscribe with one service level
         cmd = "subscription-manager subscribe --auto --servicelevel=%s" % service_level
         (ret, output) = self.runcmd(cmd, "autosubscribe with one service-level")
         if ret == 0 and ("Status:Subscribed" in output) or re.search("Status:\s+Subscribed", output):
             logger.info("It's successful to do autosubscribe with one service-level: %s." % service_level)
         else:
             raise FailException("Test Failed - Failed to auto subscribe with one service level.")
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
コード例 #21
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % case_name)
     try:
         username = RHSMConstants().get_constant("username")
         password = RHSMConstants().get_constant("password")
         self.sub_register(username, password)
         samhostip = RHSMConstants().samhostip
         cmd = "subscription-manager environments --username=%s --password=%s" % (username, password)
         (ret, output) = self.runcmd(cmd, "running environments command with no options")
         if samhostip != None and ret == 0 and "Error: Server does not support environments" in output:
             logger.info("It's successful to verify that SAM does not support environments")
         elif ret != 0 and "Error: This command requires that you specify an organization with --org" in output :
             logger.info("It's successful to check the error message when run environments with no options.")
         else:
             raise FailException("Test Failed - Failed to check the error message when run environments with no options.")
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" % self.__class__.__name__)
     try:
         try:
             self.open_subscription_manager()
             self.click_gettingstarted_menu()
             if self.check_window_open("subscription-manager-manual-window"):
                 logger.info("It's successful to check subscription_manager_help_maual.")
             else:
                 raise FailException("Test Faild - Failed to check subscription_manager_help_maual!")
             self.assert_(True, case_name)
         except Exception, e:
             logger.error("Test Failed - ERROR Message:" + str(e))
             self.assert_(False, case_name)
     finally:
         self.capture_image(case_name)
         self.close_window("subscription-manager-manual-window")
         self.restore_gui_environment()
         logger.info("========== End of Running Test Case: %s ==========" % case_name)
コード例 #23
0
 def install_givenpkg(self, testpkg):
     cmd = "yum install -y %s" % (testpkg)
     (ret, output) = self.runcmd(cmd,
                                 "install selected package %s" % testpkg)
     if ret == 0 and "Complete!" in output and "Error" not in output:
         logger.info("The package %s is installed successfully." %
                     (testpkg))
     elif ret == 1:
         if ("The subscription for following product(s) has expired"
                 in output):
             logger.info(
                 "It's successful to verify that system should not be able to access CDN bits through thumbslug  proxy when the system is expired."
             )
         else:
             logger.info(
                 "It's successful to verify that system should not be able to access CDN bits through thumbslug  proxy when the system is not attach subscriptions"
             )
     else:
         raise FailException(
             "Test Failed - The package %s is failed to install." %
             (testpkg))
コード例 #24
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         cmd = 'subscription-manager list --available --help | egrep "no-overlap|match-installed" -A1'
         (ret, output) = self.runcmd(
             cmd,
             "check subscription-manager man page for new list options")
         if ret == 0 and "shows pools which provide products that are not" in output and "already covered; only used with --available" in output and "shows only subscriptions matching products that are" in output and "currently installed; only used with --available" in output:
             logger.info(
                 "It's successful to check subscription-manager man page for new list options."
             )
         else:
             raise FailException(
                 "Test Failed - Failed to check subscription-manager man page for new list options."
             )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
コード例 #25
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         # Check the description of rhsm-debug MODULE-NAME
         cmd = "rhsm-debug --help | grep system"
         (ret, output) = self.runcmd(cmd,
                                     "check man page for repo-override")
         if ret == 0 and "Assemble system information as a tar file or directory" in output:
             logger.info(
                 "It's successful to Check the description of rhsm-debug MODULE-NAME."
             )
         else:
             raise FailException(
                 "Test Failed - Failed to Check the description of rhsm-debug MODULE-NAME."
             )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
    def test_run(self):
        case_name = self.__class__.__name__
        logger.info("========== Begin of Running Test Case %s ==========" % case_name)
        try:
            # config rhsmcertd in /etc/rhsm/rhsm.conf
            self.sub_set_certfrequency(1)
            self.sub_set_healfrequency(1)
            cmd3 = 'service rhsmcertd restart'
            (ret3, output3) = self.runcmd(cmd3, "restart rhsmcertd service")

            cmd4 = 'tail -4 /var/log/rhsm/rhsmcertd.log'
            (ret4, output4) = self.runcmd(cmd4, "restart rhsmcertd service")

            if ret4 == 0 and "healing check started: interval = 1" and "cert check started: interval = 1" and "certificates updated" in output4:
                logger.info("It's successful to logging rhsmcertd statements.")
            else:
                FailException("Test Failed - Failed to logging rhsmcertd statements.")
            self.assert_(True, case_name)
        except Exception, e:
            logger.error(str(e))
            self.assert_(False, case_name)
コード例 #27
0
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         cmd = 'subscription-manager --help'
         (ret,
          output) = self.runcmd(cmd,
                                "list subscription-manager help manual!")
         if ret == 0 and ('Primary Modules' and 'Other Modules' in output):
             logger.info(
                 "Test Successful - It's successful to list subscription-manager help manual."
             )
         else:
             raise FailException(
                 "Test Failed - Failed to list subscription-manager help manual."
             )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error(str(e))
         self.assert_(False, case_name)
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         # check the certificate version from facts
         cmd = "subscription-manager facts | grep system.certificate_version"
         (ret,
          output) = self.runcmd(cmd,
                                "check the certificate version from facts")
         if ret == 0 and "system.certificate_version: 3" in output:
             logger.info(
                 "It's successful to check the certificate version from facts."
             )
         else:
             raise FailException(
                 "Test Failed - Failed to check the certificate version from facts."
             )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error(str(e))
         self.assert_(False, case_name)
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         samhostip = RHSMConstants().samhostip
         if samhostip == None:
             logger.info(
                 "This case is just for SAM, no need to test against other servers!"
             )
         else:
             username = RHSMConstants().get_constant("username")
             password = RHSMConstants().get_constant("password")
             # create a new org without available subscriptions in SAM
             orgname = "test"
             self.create_sam_org(samhostip, orgname)
             # register and auto-attach by this account
             cmd_to_test = "subscription-manager register --username=%s --password='******' --org=%s --auto-attach" % (
                 username, password, orgname)
             (ret,
              output) = self.runcmd(cmd_to_test,
                                    "register with auto subscribe option")
             if (ret != 0) and (
                     "The system has been registered with ID" in output
             ) and (
                     "Not Subscribed" in output
             ) and ("Unable to find available subscriptions for all your installed products"
                    in output):
                 logger.info(
                     "It's successful to verify registeration with auto subscribe option if there is no compatible subscription"
                 )
             else:
                 raise FailException(
                     "Test Failed -Failed to verify registeration with auto subscribe option if there is no compatible subscription"
                 )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)
 def test_run(self):
     case_name = self.__class__.__name__
     logger.info("========== Begin of Running Test Case %s ==========" %
                 case_name)
     try:
         username = RHSMConstants().get_constant("username")
         password = RHSMConstants().get_constant("password")
         self.sub_register(username, password)
         # get baseurl
         baseurl = RHSMConstants().get_constant("baseurl")
         if "8443" in baseurl:
             baseurl = baseurl + "/candlepin"
         elif RHSMConstants().samhostip == None:
             baseurl = baseurl + "/subscription"
         else:
             baseurl = baseurl + "/sam/api"
         # get consumerid
         cmd = "subscription-manager identity | grep identity"
         (ret, output) = self.runcmd(cmd, "get consumerid")
         consumerid = output.split(':')[1].strip()
         service_level = RHSMConstants().get_constant("servicelevel")
         # call dry run bind to products by api
         cmd = "curl -k --cert /etc/pki/consumer/cert.pem --key /etc/pki/consumer/key.pem %s/consumers/%s/entitlements/dry-run?service_level=%s && echo \"\r\"" % (
             baseurl, consumerid, service_level)
         (ret, output) = self.runcmd(cmd, "dry run bind by products api")
         if ret == 0 and ('"value":"%s"' % service_level in output
                          or '"value":"%s"' %
                          (((service_level).lower()).upper()) in output):
             logger.info(
                 "It's successful to dry run bind by products api with a specified SLA."
             )
         else:
             raise FailException(
                 "Test Failed - Failed to dry run bind by products api with a specified SLA."
             )
         self.assert_(True, case_name)
     except Exception, e:
         logger.error("Test Failed - ERROR Message:" + str(e))
         self.assert_(False, case_name)