Ejemplo n.º 1
0
    def test_ba_price_update(self):
        """
        Tests that the AXBidVisor actually updates the pricing info.
        """
        bidadv = AWSBidAdvisor(REFRESH_INTERVAL, REFRESH_INTERVAL, REGION)
        od_updater = bidadv.OnDemandUpdater(bidadv)
        od_updater.get_on_demand_pricing()

        sp_updater = bidadv.SpotInstancePriceUpdater(bidadv)
        sp_updater.get_spot_price_info()

        # Verify that the pricing info was populated.
        assert len(bidadv.on_demand_price_dict) > 0
        assert len(bidadv.spot_price_list) > 0

        # Make the price dicts empty to check if they get updated.
        bidadv.on_demand_price_dict = {}
        bidadv.spot_price_list = {}

        od_updater.get_on_demand_pricing()
        sp_updater.get_spot_price_info()

        # Verify that the pricing info is populated again.
        assert len(bidadv.on_demand_price_dict) > 0
        assert len(bidadv.spot_price_list) > 0
Ejemplo n.º 2
0
 def test_ba_on_demand_pricing(self):
     """
     Tests that the AWSBidVisor correctly gets the on-demand pricing.
     """
     bidadv = AWSBidAdvisor(REFRESH_INTERVAL, REFRESH_INTERVAL, REGION)
     assert len(bidadv.on_demand_price_dict) == 0
     updater = bidadv.OnDemandUpdater(bidadv)
     updater.get_on_demand_pricing()
     assert len(bidadv.on_demand_price_dict) > 0
Ejemplo n.º 3
0
    def test_ba_get_current_price(self):
        """
        Tests that the BidAdvisor returns the most recent price information.
        """
        bidadv = AWSBidAdvisor(REFRESH_INTERVAL, REFRESH_INTERVAL, REGION)

        od_updater = bidadv.OnDemandUpdater(bidadv)
        od_updater.get_on_demand_pricing()

        sp_updater = bidadv.SpotInstancePriceUpdater(bidadv)
        sp_updater.get_spot_price_info()

        # Verify that the pricing info was populated.
        assert len(bidadv.on_demand_price_dict) > 0
        assert len(bidadv.spot_price_list) > 0

        price_info_map = bidadv.get_current_price()
        assert price_info_map["spot"] is not None
        assert price_info_map["on-demand"] is not None
Ejemplo n.º 4
0
    def test_ba_parse_row(self):
        """
        Tests that the BidAdvisor parses the rows in on-demand price information.
        """
        bidadv = AWSBidAdvisor(REFRESH_INTERVAL, REFRESH_INTERVAL, REGION)

        od_updater = bidadv.OnDemandUpdater(bidadv)
        row = {}
        row['RateCode'] = "JRTCKXETXF.6YS6EN2CT7"
        row["TermType"] = "OnDemand"
        row["PriceDescription"] = "On Demand Linux"
        row["Location"] = "US West (Oregon)"
        row["Operating System"] = "Linux"
        row["Pre Installed S/W"] = "NA"
        row["Tenancy"] = "Shared"
        row["PricePerUnit"] = "0.453"
        row["Instance Type"] = "m5.4xlarge"

        od_updater.parse_price_row(row)
        assert od_updater.bid_advisor.on_demand_price_dict[
            'm5.4xlarge'] == "0.453"

        od_updater.parse_price_row(row)
        assert od_updater.bid_advisor.on_demand_price_dict[
            'm5.4xlarge'] == "0.453"

        row["PricePerUnit"] = "0.658"
        od_updater.parse_price_row(row)
        assert od_updater.bid_advisor.on_demand_price_dict[
            'm5.4xlarge'] == "0.658"

        row["PricePerUnit"] = "0.00"
        od_updater.parse_price_row(row)
        assert od_updater.bid_advisor.on_demand_price_dict[
            'm5.4xlarge'] == "0.658"

        row['RateCode'] = "Some Random RateCode"
        od_updater.parse_price_row(row)