Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce pytest to help address time issues to run journey tests #142

Merged
merged 10 commits into from
Oct 4, 2017

Conversation

lipemorais
Copy link
Contributor

@lipemorais lipemorais commented Sep 1, 2017

What is the purpose of this Pull Request?
The purpose of this PR is use pytest to help address the long time running some journey tests usings --durations, this way we know which test takes more time to run.

What was done to achieve this purpose?
I changed way we run tests to use pytest.

How to test if it really works?
To test it you can just run pytest --verbose --durations=10 --cov-report html tests/unit after install pytest and pytest-cov using pip install pytest pytest-cov.

Who can help reviewing it?
@cuducos @jtemporal @anaschwendler

TODO

  • Update the new way to run the tests on README
  • Add a pytest.ini file

Yesterday I runned it on my machine and some tests took too long to run

==================== slowest 10 test durations =====================
4185.53s call     tests/journey/test_chamber_of_deputies_dataset.py::TestChamberOfDeputiesDataset::test_fetch_translate_clean_integration
162.20s call     tests/journey/test_federal_senate_dataset.py::TestJourneyFederalSenateDataset::test_journey_federal_senate_dataset
2.23s call     tests/journey/test_chamber_of_deputies_session_start_times_dataset.py::TestSpeechesDataset::test_fetch
1.93s call     tests/journey/test_chamber_of_deputies_official_missions_dataset.py::TestOfficialMissionsDataset::test_fetch
1.88s call     tests/journey/test_chamber_of_deputies_deputies_dataset.py::TestDeputiesDataset::test_fetch
1.66s call     tests/journey/test_chamber_of_deputies_presences_dataset.py::TestPresencesDataset::test_fetch
0.40s call     tests/journey/test_chamber_of_deputies_speeches_dataset.py::TestSpeechesDataset::test_fetch
0.00s setup    tests/journey/test_chamber_of_deputies_deputies_dataset.py::TestDeputiesDataset::test_fetch
0.00s teardown tests/journey/test_chamber_of_deputies_dataset.py::TestChamberOfDeputiesDataset::test_fetch_translate_clean_integration
0.00s teardown tests/journey/test_federal_senate_dataset.py::TestJourneyFederalSenateDataset::test_journey_federal_senate_dataset
========================= warnings summary =========================

@cuducos
Copy link
Collaborator

cuducos commented Sep 2, 2017

As usual government web API are down on weekends. Gonna re-run tests later (or on Monday)…

@cuducos
Copy link
Collaborator

cuducos commented Sep 4, 2017

@lipemorais Travis CI is still broken with an HTTP error. Meanwhile would you mind pondering on two possibilities:

  • Maybe document pytest usage in the README.md to assure a similar environment when developing locally and in the CI… what do you think about it?
  • Is the HTTP error still some external API that is broken?

@lipemorais
Copy link
Contributor Author

Maybe document pytest usage in the README.md to assure a similar environment when developing locally and in the CI… what do you think about it?

I will do it soon. :)

Is the HTTP error still some external API that is broken?
I checked the url that Toolbox tries to fetch and got 404

Here is the url: http://www.camara.leg.br/cotas/Ano-2009.csv.zip

And a print of what I got:
image

@cuducos I will add t

@cuducos
Copy link
Collaborator

cuducos commented Sep 6, 2017

Travis is green, yay! I think all we need now is a version bump ; )

@@ -20,7 +20,7 @@ def setUp(self):
def tearDown(self):
rmtree(self.path, ignore_errors=True)


@skip('Takes to long to run')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just something to test the CI or is it supposed to go to master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a test, looks that this test were making build fail using all memory available on Travis.

def test_fetch_translate_clean_integration(self):
self.subject.fetch()
files = ["Ano-{}.csv".format(n) for n in self.years]
files = ["Ano-{}.csv".format(n) for n in [2017]]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about self.years[-1:]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a attempt to make this test run without use all the resources available in Travis CI and break the build because of it. Looks that worked because it's breaking for a different reason now.

@lipemorais
Copy link
Contributor Author

There is a test breaking because this dataset is not available. :'(

http://www.senado.gov.br/transparencia/LAI/verba/2008.csv

@lipemorais
Copy link
Contributor Author

Hey! @cuducos @jtemporal @anaschwendler do you have any idea about what can I do to fix this? :(

@cuducos
Copy link
Collaborator

cuducos commented Sep 21, 2017

What about mocking the requests and using tiny fixtures instead?

@lipemorais
Copy link
Contributor Author

@cuducos
Copy link
Collaborator

cuducos commented Sep 21, 2017

Yep. An IMHO opinion depending on external services to run the suites tests is a problem per se. If I'm not wrong we adopted the journey test this way (depending on external services) as a temporary fix. As this was not a permanent solution and, given that it is broken now, it might be an interesting opportunity to sor that out.

Not sure about what others @anaschwendler @jtemporal @Irio think of that though…

@lipemorais
Copy link
Contributor Author

Hey, @cuducos @anaschwendler . Looks that it is working now. Could we re run travis?

http://www.senado.gov.br/transparencia/LAI/verba/2008.csv

@cuducos
Copy link
Collaborator

cuducos commented Sep 25, 2017

Sure thing! Just restarted it ; )

@cuducos
Copy link
Collaborator

cuducos commented Sep 25, 2017

Hasn't lasted long enough:

$ curl -I  http://www.camara.leg.br/cotas/Ano-2008.csv.zip
HTTP/1.1 404 Not Found

@lipemorais
Copy link
Contributor Author

Looks now that http://www.camara.leg.br/cotas/Ano-2008.csv.zip is out. :'(

image

@lipemorais
Copy link
Contributor Author

I just runned it a ALL tests and where all green. :)

GREEN BUILD

Could we rerun it or just merge?

@cuducos
Copy link
Collaborator

cuducos commented Oct 3, 2017

Yay! May we have a version bump?

@lipemorais
Copy link
Contributor Author

Yay! May we have a version bump?

Done in a7a2dc2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants