orchestracities / ngsi-timeseries-api

QuantumLeap: a FIWARE Generic Enabler to support the usage of NGSIv2 (and NGSI-LD experimentally) data in time-series databases
https://quantumleap.rtfd.io/
MIT License
38 stars 49 forks source link

refactor reporter tests to use lovely-pytest-docker #531

Open chicco785 opened 3 years ago

chicco785 commented 3 years ago

Is your feature request related to a problem? Please describe. Currently reporter tests depend on external startup of docker, this limits the scenario testing possibilities and is not programmable.

e.g. how to test what happens when a db service goes down?

Describe the solution you'd like tests starts and stop docker as needed.

Describe alternatives you've considered Leave everything as it is

Additional context N/A

github-actions[bot] commented 3 years ago

Stale issue message

pooja1pathak commented 2 years ago

Hi @c0c0n3 @chicco785 I have gone through this issue and https://github.com/lovelysystems/lovely-pytest-docker , I have concluded below points:

  1. We need to update conftest.py for docker fixtures.
  2. We need to update all the test methods to use fixtures.
  3. We need to add dependency of lovely-pytest-docker which can be installed using pip.
  4. We can use docker-compose.yml files which are already present in the test folder.

I will start working as per my understanding and will raise PR for the same. Please correct me if I misunderstood or missed any point.

chicco785 commented 2 years ago

@pooja1pathak fyi, we are already lovely-pytest-docker, but not for reporter test.

see for example: https://github.com/orchestracities/ngsi-timeseries-api/blob/master/src/translators/tests/conftest.py#L26

c0c0n3 commented 2 years ago

hi guys, I forgot to mention we already have a docker util that avoids the dependency on external libs:

and here's an example usage

going forward we should avoid shell scripts as much as possible and put the test control logic in Python whenever possible, like we've done in the translator and wq...

c0c0n3 commented 2 years ago

also in the same vein, we should start thinking about how to get rid of docker boilerplate, see e.g. #598 about it.

Ravisaketi commented 2 years ago

@pooja1pathak fyi, we are already lovely-pytest-docker, but not for reporter test.

see for example: https://github.com/orchestracities/ngsi-timeseries-api/blob/master/src/translators/tests/conftest.py#L26

hi @chicco785 @c0c0n3 for reporter also we have already implemented lovely-pytest-docker but it does not work like translators. https://github.com/orchestracities/ngsi-timeseries-api/blob/master/src/reporter/tests/conftest.py#L29

Ravisaketi commented 2 years ago

Hi @c0c0n3 @chicco785 I have compared conftest.py in both reporter and translators but I found no difference in them and I have also investigated on wq/tests/conftest.py https://github.com/orchestracities/ngsi-timeseries-api/blob/master/src/wq/tests/conftest.py where I found differences do you need to apply similar kind of changes in reporter and translators.

c0c0n3 commented 2 years ago

Hi @Necravisaketi thanks for looking into this, much appreciated! For the time being you can leave wq/tests/conftest.py as is---it's using the exact same approach but with a different implementation. At a later stage we can decide if we should keep our own Docker utils or rather switch everywhere to lovely docker. The important thing for now is that we start moving away from shell scripts and do as much as we can in Python.