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

More thorough testing with pytest #68

Merged
merged 25 commits into from
Nov 7, 2019
Merged

Conversation

consideRatio
Copy link
Member

@consideRatio consideRatio commented Oct 22, 2019

Closes #67.

PR Status

Ready for review -> merge.

About test setup

The tests are setup by creating temporary git repositories where we copy a content. In the master branch of the temp git repo we put a test helm chart. In the gh-pages branch of the temp git repo we put a test helm chart repository containing the important index.yaml file.

Many tests work by capturing the output while running chartpress, and verifying that we find the right kind of statements in the output. It can be traces from chartpress itself, such as "Updating testchart/values.yaml with..." but also from docker such as "Successfully tagged..." or the helm package command etc.

Added functionality: local chart

The git_remote function previously updated a passed "jupyterhub/helm-chart" string to be git@github.com:jupyterhub/helm-chart.git or similar. As I wanted to run tests without external dependencies etc, I made this function support being passed a . string without updating it, which allowed me to work directly with the gh-pages branch of the git repository chartpress is running on.

This also opens up the new possibility of not creating a dedicated helm-chart repo for the helm chart.

bugfix: version bumping depending on what paths?

In this PR there is a slight change of behavior because of a bug fix.

chartpress.yaml
README.md
images/
- testimage
testchart/
- templates/
- values.yaml
- Chart.yaml

Previously, a change to this folder would give us a new version, now a change to the README.md wont. So it's not a big deal.

  • For charts regarding version bumping, chartpress is considering the paths in chartpress.yaml, the helm charts folder, and chartpress.yaml, and any change to dependent images build context, Dockerfile or additional image paths.
  • For images regarding version bumping, chartpress is considering the paths in chartpress.yaml, the build context, the Dockerfile, and chartpress.yaml.

With this git_repo fixture, we can have a clean slate with fresh data to itneract with.
@consideRatio consideRatio changed the title [WIP] Thorough testing with pytest Thorough testing with pytest Oct 23, 2019
@consideRatio consideRatio changed the title Thorough testing with pytest [WIP] Thorough testing with pytest Oct 23, 2019
@consideRatio
Copy link
Member Author

consideRatio commented Oct 23, 2019

UPDATE: Resolved without me understanding properly what happened.


The test succeeds on my computer, but when I run them on travis and I arrive at the part where I do various monkeypatching things fail without providing an non-negative returncode in the following way:

image

If someone has insight about what goes on here I'd be very interested. At this point in the code, we have already done various things, like used the git_repo fixture, and made multiple commits to a temp git repo in a temp directory etc. What happens for the first time in the test where it crashes like this, is that we run chartpress.main([]) for the first time. So I figure that is what causes things for some reason.

Copy link
Member

@minrk minrk left a comment

Choose a reason for hiding this comment

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

Woo! Super happy to see these tests getting added.

chartpress.py Show resolved Hide resolved
@consideRatio consideRatio changed the title [WIP] Thorough testing with pytest Thorough testing with pytest Oct 24, 2019
@consideRatio consideRatio changed the title Thorough testing with pytest More thorough testing with pytest Oct 24, 2019
@consideRatio
Copy link
Member Author

The cache issue in #68 (comment) resolved, or perhaps rather stopped messing with the rendered output that made me thing something was wrong. I added back lru_cache and and started clearing the lru_cache when it had become outdated using the .clear_cache() function.

@consideRatio consideRatio changed the title More thorough testing with pytest [WIP] More thorough testing with pytest Oct 28, 2019
- Bumping chart version on changes to chartpress.yaml, the helm chart
folder, its dependent images, and optionally additional paths. Previous
behavior was to bump chart version on any change to the folder where
chartpress.yaml resided and optionally additional paths.
- Bumping image version on change to Dockerfile residing outside of
image build context should now work.
@consideRatio consideRatio changed the title [WIP] More thorough testing with pytest More thorough testing with pytest Oct 28, 2019
@minrk minrk merged commit f9398ed into jupyterhub:master Nov 7, 2019
@minrk
Copy link
Member

minrk commented Nov 7, 2019

This is excellent, great job!

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.

Setup more thorough pytest tests
3 participants