scality / metalk8s

An opinionated Kubernetes distribution with a focus on long-term on-prem deployments
Apache License 2.0
363 stars 45 forks source link

metric server empty endpoint test failure #393

Open Zempashi opened 6 years ago

Zempashi commented 6 years ago
=================================== FAILURES ===================================
_________________ test_check_node_statistics_can_be_retrieved __________________
request = <FixtureRequest for <Function 'test_check_node_statistics_can_be_retrieved'>>
    assert response_code == 200
>   assert response_headers['content-type'] == 'application/json'
tests/post/test_metrics_server.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/tests/lib/python3.6/site-packages/pytest_bdd/scenario.py:195: in _execute_scenario
    _execute_step_function(request, scenario, step, step_func)
.tox/tests/lib/python3.6/site-packages/pytest_bdd/scenario.py:137: in _execute_step_function
    step_func(**kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
request = <FixtureRequest for <Function 'test_check_node_statistics_can_be_retrieved'>>
inventory_obj = <utils.helper.Inventory object at 0x7f9d305a93c8>
group_name = 'k8s-cluster'
    @pytest_bdd.then(pytest_bdd.parsers.parse(
        'I should count as many nodes as {group_name} hosts'))
    def node_count_match(request, inventory_obj, group_name):
>       assert len(request.raw_response['items']) == \
            len(inventory_obj.get_groups_dict()[group_name])
E       AssertionError: assert 0 == 1
E        +  where 0 = len([])
E        +  and   1 = len(['ci-metalk8s'])
NicolasT commented 6 years ago

TBH, I'm not sure how to handle this in a BDD model... The 'problem' is metrics-server doesn't immediately start providing metrics after startup. I already added a step to wait for it to be 'available' (i.e. not return HTTP 500), but I guess some more waiting time or retries are required before it actually exposes metrics.

And I have no clue how to express this in BDD scenarios. Any ideas, @Zempashi ?

Zempashi commented 6 years ago

We should create a function to wait for metrics to come up (real metrics, not just 'available' state). And then call it in the wait step or as part of testing step. That's not really related to BDD ?