Beispiel #1
0
    def testAnswerQueryWhenMatchingToolsExistAndQuerySpecifiesAf(self):
        """Resolver should take into account address family when specified."""
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.tool_address_family = message.ADDRESS_FAMILY_IPv6

        mock_fetched_tools = [
            _createSliverTool(_TOOL_ID),
            _createSliverTool(_TOOL_ID)
        ]

        # AllResolver should not do any additional filtering on the tools it
        # fetched.
        query_results_expected = mock_fetched_tools

        # Make sure the resolver is fetching only tools with IPv6 interface
        # online that match the specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID,
            address_family=message.ADDRESS_FAMILY_IPv6,
            status=message.STATUS_ONLINE)

        self.assertQueryResultMultiTool(query, mock_fetched_tools,
                                        query_results_expected,
                                        tool_properties_expected)
Beispiel #2
0
    def testAnswerQueryWhenFourToolsAreEquallyClosest(self):
        """When exactly four tools tie for closest, return those four."""
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.latitude = 0.0
        query.longitude = 0.0

        mock_fetched_tools = [
            _createSliverTool(
                _TOOL_ID, site_id='abc01', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc02', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc03', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc04', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='cba01', latitude=5.0, longitude=5.0)
        ]  # yapf: disable

        # Result should be the four closest tools
        query_results_expected = mock_fetched_tools[:4]

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        self.assertQueryResultMultiTool(query, mock_fetched_tools,
                                        query_results_expected,
                                        tool_properties_expected)
Beispiel #3
0
    def testAnswerQueryWhenSingleToolIsClosestAndQuerySpecifiesAf(self):
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.latitude = 0.0
        query.longitude = 0.0
        query.tool_address_family = message.ADDRESS_FAMILY_IPv4

        close_tool = _createSliverTool(_TOOL_ID,
                                       site_id='abc01',
                                       latitude=1.0,
                                       longitude=1.0)
        far_tool = _createSliverTool(_TOOL_ID,
                                     site_id='cba01',
                                     latitude=5.0,
                                     longitude=5.0)

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID,
            address_family=message.ADDRESS_FAMILY_IPv4,
            status=message.STATUS_ONLINE)

        mock_fetched_tools = [close_tool, far_tool]
        self.assertQueryResultSingleTool(query, mock_fetched_tools, close_tool,
                                         tool_properties_expected)
Beispiel #4
0
    def testAnswerQueryWhenFewerThanFourToolsMatch(self):
        """When fewer than four tools match, return whatever matches."""
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.latitude = 0.0
        query.longitude = 0.0

        mock_fetched_tools = [
            _createSliverTool(
                _TOOL_ID, site_id='abc01', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc02', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='cba01', latitude=5.0, longitude=5.0)
        ]  # yapf: disable

        query_results_expected = mock_fetched_tools

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        self.assertQueryResultMultiTool(query, mock_fetched_tools,
                                        query_results_expected,
                                        tool_properties_expected)
Beispiel #5
0
 def testOnlyReturnMlab1(self):
     self.initToolIdSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a')
     for tool in self.fetcher.fetch(tool_properties):
         self.assertTrue('mlab1' in tool.fqdn)
         self.assertFalse('mlab2' in tool.fqdn)
Beispiel #6
0
    def testAnswerQueryReturnsRandomSubsetWhenQueryIsMissingLatLon(self):
        """When lat/lon is missing, expect a random subset of tools."""
        # TODO(mtlynch): This behavior is confusing because it is inconsistent
        # with the other resolvers that return None when required attributes are
        # missing from the query. Change so that all are consistent.
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID

        mock_fetched_tools = [
            _createSliverTool(
                _TOOL_ID, site_id='abc01', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc02', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc03', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc04', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='cba01', latitude=5.0, longitude=5.0)
        ]  # yapf: disable

        # When lat/lon is missing, resolver performs no additional filtering
        # after fetch
        filtered_tools_expected = mock_fetched_tools

        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        self.assertQueryResultMultiToolWithRandomSample(
            query, mock_fetched_tools, filtered_tools_expected, 4,
            tool_properties_expected)
Beispiel #7
0
    def testAnswerQueryReturnsRandomSubsetWhenQueryIsMissingLatLonLowCandidates(
            self):
        """When lat/lon is missing, expect a random subset of tools.

        If the number of matching candidates is lower than the number of tools
        requested, return all the matching candidates.
        """
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID

        mock_fetched_tools = [
            _createSliverTool(
                _TOOL_ID, site_id='abc01', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc02', latitude=1.0, longitude=1.0)
        ]  # yapf: disable

        # When lat/lon is missing, resolver performs no additional filtering
        # after fetch
        filtered_tools_expected = mock_fetched_tools

        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        # Normally we expect a random sample of 4, but there are only 2
        # candidates in the set
        self.assertQueryResultMultiToolWithRandomSample(
            query, mock_fetched_tools, filtered_tools_expected, 2,
            tool_properties_expected)
Beispiel #8
0
    def testAnswerQueryWhenSingleToolIsClosest(self):
        """When a single tool is closest, return that tool."""
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.latitude = 0.0
        query.longitude = 0.0

        close_tool = _createSliverTool(_TOOL_ID,
                                       site_id='abc01',
                                       latitude=1.0,
                                       longitude=1.0)
        far_tool = _createSliverTool(_TOOL_ID,
                                     site_id='cba01',
                                     latitude=5.0,
                                     longitude=5.0)

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        mock_fetched_tools = [close_tool, far_tool]
        client_signature_fetcher.ClientSignatureFetcher(
        ).fetch.return_value = 1.0
        self.assertQueryResultSingleTool(query, mock_fetched_tools, close_tool,
                                         tool_properties_expected)
Beispiel #9
0
 def testFetchToolsWithOnlineIpv6(self):
     self.initStatusSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a',
         status=message.STATUS_ONLINE,
         address_family=message.ADDRESS_FAMILY_IPv6)
     self.verifyPropertiesReturnExpectedSiteIds(('abc01', 'xyz01'),
                                                tool_properties)
Beispiel #10
0
 def testFetchAlwaysReturnsNoResultsWhenMetroIsSet(self):
     """Memcache fetcher has no knowledge of metros, so returns nothing."""
     self.createSliverTool(tool_id='mock_tool_a',
                           site_id='abc01',
                           country='CountryA',
                           status_ipv4=message.STATUS_ONLINE,
                           status_ipv6=message.STATUS_ONLINE)
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', metro='abc')
     self.verifyPropertiesReturnExpectedSiteIds([], tool_properties)
Beispiel #11
0
 def testFetchFailsOverToDatastoreWhenDataIsNotInMemcache(self):
     sliver_tool_fetcher.SliverToolFetcherMemcache().fetch.return_value = []
     # The mock response is just ints here for simplicity, though the real
     # function returns SliverTool objects.
     mock_datastore_response = [4, 5, 6]
     sliver_tool_fetcher.SliverToolFetcherDatastore().fetch.return_value = (
         mock_datastore_response)
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a')
     fetcher_results_actual = self.fetcher.fetch(tool_properties)
     self.assertSequenceEqual(mock_datastore_response,
                              fetcher_results_actual)
Beispiel #12
0
    def testFetchDoesNotHitDatastoreIfMemcacheHasRequiredData(self):
        # The mock response is just ints here for simplicity, though the real
        # function returns SliverTool objects.
        mock_memcache_response = [1, 2, 3]
        sliver_tool_fetcher.SliverToolFetcherMemcache().fetch.return_value = (
            mock_memcache_response)
        tool_properties = sliver_tool_fetcher.ToolProperties(
            tool_id='mock_tool_a')
        fetcher_results_actual = self.fetcher.fetch(tool_properties)
        self.assertSequenceEqual(mock_memcache_response,
                                 fetcher_results_actual)

        # Verify that we did not attempt to read from the Datastore
        self.assertFalse(
            sliver_tool_fetcher.SliverToolFetcherDatastore().fetch.called)
Beispiel #13
0
 def testRoundRobin(self):
     self.initToolSetForRoundRobin()
     tool_properties = sliver_tool_fetcher.ToolProperties(tool_id='rr_tool')
     rr_counter = [0, 0, 0]
     for i in range(1, 10000):
         tool = self.fetcher.fetch(tool_properties)
         self.assertEqual(1, len(tool))
         if tool[0].server_id == "mlab1":
             rr_counter[0] += 1
         if tool[0].server_id == "mlab2":
             rr_counter[1] += 1
         if tool[0].server_id == "mlab3":
             rr_counter[2] += 1
     # Ideally each server should have count around 3333.
     # The bar of the test was set for 10% to allow for variation
     # caused by randomness of site selection.
     self.assertGreater(rr_counter[0], 3000)
     self.assertGreater(rr_counter[1], 3000)
     self.assertGreater(rr_counter[2], 3000)
Beispiel #14
0
def _tool_properties_from_query(query):
    """Create ToolProperties from a LookupQuery.

    Creates a ToolProperties object for use with a resolver, based on a
    LookupQuery. Note that it only initializes common properties shared
    by all resolvers (e.g. status, tool_id) whereas resolver-specific properties
    (e.g. country, metro) are not initialized here.

    Args:
        query: LookupQuery from which to create ToolProperties

    Returns:
        A ToolProperties object initialized from the query provided.
    """
    tool_properties = sliver_tool_fetcher.ToolProperties(
        tool_id=query.tool_id, status=message.STATUS_ONLINE)
    if query.tool_address_family:
        tool_properties.address_family = query.tool_address_family
    return tool_properties
Beispiel #15
0
    def testAnswerQueryWhenMatchingToolsExist(self):
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID

        mock_fetched_tools = [
            _createSliverTool(_TOOL_ID),
            _createSliverTool(_TOOL_ID)
        ]

        # AllResolver should not do any additional filtering on the tools it
        # fetched.
        query_results_expected = mock_fetched_tools

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        self.assertQueryResultMultiTool(query, mock_fetched_tools,
                                        query_results_expected,
                                        tool_properties_expected)
Beispiel #16
0
    def testAnswerQueryWhenMoreThanFourToolsFromDifferentSitesAreEquallyClosest(
            self):
        """When more than four tools tie for closest, randomly select four."""
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.latitude = 0.0
        query.longitude = 0.0

        mock_fetched_tools = [
            _createSliverTool(
                _TOOL_ID, site_id='aaa01', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='bbb01', latitude=-1.0, longitude=-1.0),
            _createSliverTool(
                _TOOL_ID, site_id='ccc01', latitude=-1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='ddd01', latitude=1.0, longitude=-1.0),
            _createSliverTool(
                _TOOL_ID, site_id='eee01', latitude=-1.0, longitude=-1.0),
            _createSliverTool(
                _TOOL_ID, site_id='fff01', latitude=-1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='ggg01', latitude=5.0, longitude=5.0)
        ]  # yapf: disable

        # The mock shuffle reverses the list, so we expect items 2...6 in
        # reverse order.
        query_results_expected = mock_fetched_tools[-2:-6:-1]

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        client_signature_fetcher.ClientSignatureFetcher(
        ).fetch.return_value = 1.0

        self.assertQueryResultWithRandomShuffle(query, mock_fetched_tools,
                                                query_results_expected,
                                                tool_properties_expected)
Beispiel #17
0
    def testAnswerQueryWhenMultipleToolsAreEquallyClose(self):
        """When multiple tools are equally closest, randomly select one."""
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.latitude = 0.0
        query.longitude = 0.0

        equidistant_tools = (_createSliverTool(_TOOL_ID,
                                               site_id='aaa01',
                                               latitude=1.0,
                                               longitude=5.0),
                             _createSliverTool(_TOOL_ID,
                                               site_id='bbb01',
                                               latitude=5.0,
                                               longitude=1.0))

        mock_fetched_tools = [
            _createSliverTool(_TOOL_ID,
                              site_id='ccc01',
                              latitude=10.0,
                              longitude=10.0),
            _createSliverTool(_TOOL_ID,
                              site_id='ddd01',
                              latitude=20.0,
                              longitude=20.0)
        ]
        mock_fetched_tools.extend(equidistant_tools)

        query_results_expected = [equidistant_tools[-1]]

        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        client_signature_fetcher.ClientSignatureFetcher(
        ).fetch.return_value = 1.0

        self.assertQueryResultWithRandomShuffle(query, mock_fetched_tools,
                                                query_results_expected,
                                                tool_properties_expected)
Beispiel #18
0
    def testAnswerQueryChoosesRandomlyAmongOnlineTools(self):
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.tool_address_family = message.ADDRESS_FAMILY_IPv6

        mock_fetched_tools = (_createSliverTool(_TOOL_ID, site_id='aaa01'),
                              _createSliverTool(_TOOL_ID, site_id='bbb01'),
                              _createSliverTool(_TOOL_ID, site_id='ccc01'),
                              _createSliverTool(_TOOL_ID, site_id='ddd01'))

        # Random resolver performs no additional filtering after the fetch.
        filtered_tools_expected = mock_fetched_tools

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID,
            address_family=message.ADDRESS_FAMILY_IPv6,
            status=message.STATUS_ONLINE)

        self.assertQueryResultSingleToolWithRandomChoice(
            query, mock_fetched_tools, filtered_tools_expected,
            tool_properties_expected)
Beispiel #19
0
    def testAnswerQueryChoosesRandomlyAmongToolsInMetro(self):
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.metro = 'aaa'
        query.tool_address_family = message.ADDRESS_FAMILY_IPv4

        mock_fetched_tools = (_createSliverTool(_TOOL_ID, site_id='aaa01'),
                              _createSliverTool(_TOOL_ID, site_id='aaa02'),
                              _createSliverTool(_TOOL_ID, site_id='aaa03'))

        filtered_tools_expected = mock_fetched_tools

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID in the specified metro.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID,
            status=message.STATUS_ONLINE,
            address_family=message.ADDRESS_FAMILY_IPv4,
            metro=query.metro)

        self.assertQueryResultSingleToolWithRandomChoice(
            query, mock_fetched_tools, filtered_tools_expected,
            tool_properties_expected)
Beispiel #20
0
    def testAnswerQueryWhenMoreThanFourToolsAreEquallyClosest(self):
        """When more than four tools tie for closest, randomly select four."""
        query = lookup_query.LookupQuery()
        query.tool_id = _TOOL_ID
        query.latitude = 0.0
        query.longitude = 0.0

        mock_fetched_tools = [
            _createSliverTool(
                _TOOL_ID, site_id='abc01', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc02', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc03', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc04', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc05', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='abc06', latitude=1.0, longitude=1.0),
            _createSliverTool(
                _TOOL_ID, site_id='cba01', latitude=5.0, longitude=5.0)
        ]  # yapf: disable

        # The mock shuffle reverses the list, so we expect items 2...6 in
        # reverse order.
        query_results_expected = mock_fetched_tools[-2:-6:-1]

        # Make sure the resolver is fetching only online tools that match the
        # specified tool ID.
        tool_properties_expected = sliver_tool_fetcher.ToolProperties(
            tool_id=_TOOL_ID, status=message.STATUS_ONLINE)

        self.assertQueryResultWithRandomShuffle(query, mock_fetched_tools,
                                                query_results_expected,
                                                tool_properties_expected)
Beispiel #21
0
    def update_sliver_tools_status(self, slice_status, tool_id, family):
        """Updates status of sliver tools in input slice.

        Args:
            slice_status: A dict that contains the status of the
                slivers in the slice {key=fqdn, status:online|offline}
            tool_id: A string representing the fqdn that resolves
                to an IP address.
            family: Address family to update.
        """
        sliver_tools = sliver_tool_fetcher.SliverToolFetcherDatastore().fetch(
            sliver_tool_fetcher.ToolProperties(tool_id=tool_id,
                                               all_slivers=True))
        updated_sliver_tools = []
        for sliver_tool in sliver_tools:

            if sliver_tool.fqdn not in slice_status:
                logging.info('Monitoring does not know sliver %s.',
                             sliver_tool.fqdn)
                if family == '_ipv6':
                    # We don't want to entirely remove a sliver from memcache
                    # just because IPv6 information is missing from monitoring.
                    # If IPv6 monitoring information is missing, then just flag
                    # IPv6 as offline, and continue as usual.
                    slice_status[sliver_tool.fqdn] = {}
                    slice_status[sliver_tool.fqdn][
                        'status'] = message.STATUS_OFFLINE
                    # Update tool_extra to signal that _ipv6 is not known.
                    slice_status[sliver_tool.fqdn][
                        'tool_extra'] = constants.PROMETHEUS_TOOL_EXTRA + ' (Family "_ipv6" for sliver not known by monitoring).'

                else:
                    # If monitoring data doesn't exist for this tool, append
                    # the sliver_tool unmodified to the list, since in the
                    # absence of status data we are better off having stale
                    # data than marking the sliver as down.
                    updated_sliver_tools.append(sliver_tool)
                    continue

            if family == '':
                if sliver_tool.sliver_ipv4 == message.NO_IP_ADDRESS:
                    if sliver_tool.status_ipv4 == message.STATUS_ONLINE:
                        logging.warning('Setting IPv4 status of %s to offline '\
                                        'due to missing IP.', sliver_tool.fqdn)
                        sliver_tool.status_ipv4 = message.STATUS_OFFLINE
                else:
                    if (sliver_tool.status_ipv4 !=
                            slice_status[sliver_tool.fqdn]['status'] or
                            sliver_tool.tool_extra !=
                            slice_status[sliver_tool.fqdn]['tool_extra']):
                        sliver_tool.status_ipv4 = \
                          slice_status[sliver_tool.fqdn]['status']
                        sliver_tool.tool_extra = \
                          slice_status[sliver_tool.fqdn]['tool_extra']
            elif family == '_ipv6':
                if sliver_tool.sliver_ipv6 == message.NO_IP_ADDRESS:
                    if sliver_tool.status_ipv6 == message.STATUS_ONLINE:
                        logging.warning('Setting IPv6 status for %s to offline'\
                                        ' due to missing IP.', sliver_tool.fqdn)
                        sliver_tool.status_ipv6 = message.STATUS_OFFLINE
                else:
                    if (sliver_tool.status_ipv6 !=
                            slice_status[sliver_tool.fqdn]['status'] or
                            sliver_tool.tool_extra !=
                            slice_status[sliver_tool.fqdn]['tool_extra']):
                        sliver_tool.status_ipv6 = \
                          slice_status[sliver_tool.fqdn]['status']
                        sliver_tool.tool_extra = \
                          slice_status[sliver_tool.fqdn]['tool_extra']
            else:
                logging.error('Unexpected address family: %s.', family)
                continue

            sliver_tool.update_request_timestamp = long(time.time())
            updated_sliver_tools.append(sliver_tool)

        if updated_sliver_tools:
            try:
                db.put(updated_sliver_tools)
            except db.TransactionFailedError as e:
                logging.error(
                    'Error updating sliver statuses in datastore. Some' \
                    'statuses might be outdated. %s', e)

            if not memcache.set(tool_id,
                                updated_sliver_tools,
                                namespace=constants.MEMCACHE_NAMESPACE_TOOLS):
                logging.error('Failed to update sliver status in memcache.')
Beispiel #22
0
 def testFetchToolC(self):
     self.initToolIdSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_c')
     self.verifyPropertiesReturnExpectedSiteIds(('abc01', 'abc03'),
                                                tool_properties)
Beispiel #23
0
 def testFetchNonExistentTool(self):
     self.initToolIdSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='no_exist_tool')
     self.verifyPropertiesReturnExpectedSiteIds([], tool_properties)
Beispiel #24
0
 def testFetchToolsInNonExistentCountry(self):
     self.initCountrySiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', country='non_existent_country')
     self.verifyPropertiesReturnExpectedSiteIds([], tool_properties)
Beispiel #25
0
 def testFetchWhenNoAfIsSpecifiedButStatusIsOmittedIgnoreAf(self):
     self.initStatusSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', address_family=message.ADDRESS_FAMILY_IPv6)
     self.verifyPropertiesReturnExpectedSiteIds(
         ('abc01', 'abc02', 'abc03', 'xyz01'), tool_properties)
Beispiel #26
0
 def testFetchToolsInMetroDefWithAtLeastOneOnlineInterface(self):
     self.initMetroSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', metro='def', status=message.STATUS_ONLINE)
     self.verifyPropertiesReturnExpectedSiteIds(('def02', ),
                                                tool_properties)
Beispiel #27
0
 def testFetchToolsInNonExistentMetro(self):
     self.initMetroSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', metro='qqq')
     self.verifyPropertiesReturnExpectedSiteIds([], tool_properties)
Beispiel #28
0
 def testFetchToolsInMetroXyz(self):
     self.initMetroSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', metro='xyz')
     self.verifyPropertiesReturnExpectedSiteIds(('xyz01', ),
                                                tool_properties)
Beispiel #29
0
 def testFetchToolsWithAtLeastOneOfflineInterface(self):
     self.initStatusSiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', status=message.STATUS_OFFLINE)
     self.verifyPropertiesReturnExpectedSiteIds(('abc02', 'abc03', 'xyz01'),
                                                tool_properties)
Beispiel #30
0
 def testFetchToolsInCountryB(self):
     self.initCountrySiteGroup()
     tool_properties = sliver_tool_fetcher.ToolProperties(
         tool_id='mock_tool_a', country='CountryB')
     self.verifyPropertiesReturnExpectedSiteIds(('xyz01', ),
                                                tool_properties)