X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FDropRateSearch.py;h=d090306cc5ffdbf8182f3de3f6f667319d29e7e2;hb=374ea2f45d17f361aa612becba657ecaade0d0b5;hp=912d2e9f53fd8a0ef5a562933c5b6b46401dfb88;hpb=4c6fe5602edcbd9857a846e5b13a21d5c671a2c8;p=csit.git diff --git a/resources/libraries/python/DropRateSearch.py b/resources/libraries/python/DropRateSearch.py index 912d2e9f53..d090306cc5 100644 --- a/resources/libraries/python/DropRateSearch.py +++ b/resources/libraries/python/DropRateSearch.py @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Cisco and/or its affiliates. +# Copyright (c) 2019 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -403,44 +403,13 @@ class DropRateSearch(object): while True: res = [] for dummy in range(self._max_attempts): - res.append(self.measure_loss(rate, self._frame_size, - self._loss_acceptance, - self._loss_acceptance_type, - traffic_type)) + res.append(self.measure_loss( + rate, self._frame_size, self._loss_acceptance, + self._loss_acceptance_type, traffic_type)) res = self._get_res_based_on_search_type(res) - if self._search_linear_direction == SearchDirection.BOTTOM_UP: - # loss occurred and it was above acceptance criteria - if not res: - # if this is first run then we didn't find drop rate - if prev_rate is None: - self._search_result = SearchResults.FAILURE - self._search_result_rate = None - # else we found the rate, which is value from previous run - else: - self._search_result = SearchResults.SUCCESS - self._search_result_rate = prev_rate - return - # there was no loss / loss below acceptance criteria - elif res: - prev_rate = rate - rate += self._rate_linear_step - if rate > self._rate_max: - if prev_rate != self._rate_max: - # one last step with rate set to _rate_max - rate = self._rate_max - continue - else: - self._search_result = SearchResults.SUCCESS - self._search_result_rate = prev_rate - return - else: - continue - else: - raise RuntimeError("Unknown search result") - - elif self._search_linear_direction == SearchDirection.TOP_DOWN: + if self._search_linear_direction == SearchDirection.TOP_DOWN: # loss occurred, decrease rate if not res: prev_rate = rate @@ -466,8 +435,6 @@ class DropRateSearch(object): else: raise Exception("Unknown search direction") - raise Exception("Wrong codepath") - def verify_search_result(self): """Fail if search was not successful. @@ -475,11 +442,10 @@ class DropRateSearch(object): :rtype: tuple :raises Exception: If search failed. """ - if self._search_result == SearchResults.FAILURE: - raise Exception('Search FAILED') - elif self._search_result in [SearchResults.SUCCESS, - SearchResults.SUSPICIOUS]: + if self._search_result in [ + SearchResults.SUCCESS, SearchResults.SUSPICIOUS]: return self._search_result_rate, self.get_latency() + raise Exception('Search FAILED') def binary_search(self, b_min, b_max, traffic_type, skip_max_rate=False, skip_warmup=False):