Provide Amphora stats for Octavia no-op drivers
So far, when Octavia was running with noop drivers, there were no amphora statistics data provided and 404 was returned as the AmphoraStatistics object was not created, and therefore not found. This patch adds fake statistics to amphora noop driver. Closes-Bug: #2030774 Change-Id: Ib65e459bcd10a5ab877c0cf6f234d634d25d1e55
This commit is contained in:
parent
7310986de9
commit
0c367b4fed
|
@ -11,10 +11,14 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import random
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from octavia.amphorae.drivers import driver_base
|
||||
from octavia.common import data_models
|
||||
from octavia.db import api as db_apis
|
||||
from octavia.db import repositories
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -34,6 +38,21 @@ class NoopManager(object):
|
|||
self.amphoraconfig[(listener.id, amphora_id)] = (
|
||||
listener, amphora_id, timeout_dict, "update_amp")
|
||||
|
||||
# Add some dummy stats to the DB when using noop driver
|
||||
listener_stats_repo = repositories.ListenerStatisticsRepository()
|
||||
stats_obj = data_models.ListenerStatistics(
|
||||
listener_id=listener.id,
|
||||
amphora_id=amphora.id,
|
||||
bytes_in=random.randrange(1000000000),
|
||||
bytes_out=random.randrange(1000000000),
|
||||
active_connections=random.randrange(1000000000),
|
||||
total_connections=random.randrange(1000000000),
|
||||
request_errors=random.randrange(1000000000),
|
||||
received_time=float(random.randrange(1000000000)),
|
||||
)
|
||||
listener_stats_repo.replace(session=db_apis.get_session(),
|
||||
stats_obj=stats_obj)
|
||||
|
||||
def update(self, loadbalancer):
|
||||
LOG.debug("Amphora %s no-op, update listener %s, vip %s",
|
||||
self.__class__.__name__,
|
||||
|
|
|
@ -57,7 +57,8 @@ class TestNoopAmphoraLoadBalancerDriver(base.TestCase):
|
|||
constants.CONN_MAX_RETRIES: 3,
|
||||
constants.CONN_RETRY_INTERVAL: 4}
|
||||
|
||||
def test_update_amphora_listeners(self):
|
||||
@mock.patch('octavia.db.api.get_session')
|
||||
def test_update_amphora_listeners(self, mock_session):
|
||||
self.driver.update_amphora_listeners(self.load_balancer, self.amphora,
|
||||
self.timeout_dict)
|
||||
self.assertEqual((self.listener, self.amphora.id, self.timeout_dict,
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
other:
|
||||
- |
|
||||
Add fake Amphora stats for when Octavia runs in noop mode / using
|
||||
noop drivers.
|
Loading…
Reference in New Issue