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

spec: integration tests #69

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

spec: integration tests #69

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 13, 2023

We have already moved the legacy tests to a folder called integration, because we want to use them for real integration tests against the Hetzner API. This PR applies the necessary changes to the existing tests so that they run successfully in a non-empty cloud project.

Closes #61

@codecov-commenter
Copy link

codecov-commenter commented Jan 13, 2023

Codecov Report

Merging #69 (7e114c1) into master (170a91a) will decrease coverage by 0.18%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master      #69      +/-   ##
==========================================
- Coverage   98.42%   98.24%   -0.19%     
==========================================
  Files         119       96      -23     
  Lines        4266     2627    -1639     
==========================================
- Hits         4199     2581    -1618     
+ Misses         67       46      -21     
Impacted Files Coverage Δ
lib/hcloud/abstract_resource.rb 88.99% <0.00%> (-9.18%) ⬇️
lib/hcloud/typhoeus_ext.rb 86.20% <0.00%> (-3.45%) ⬇️
lib/hcloud/client.rb 95.78% <0.00%> (-3.16%) ⬇️
spec/integration/datacenter_spec.rb
spec/integration/firewall_spec.rb
spec/integration/iso_spec.rb
spec/integration/location_spec.rb
spec/integration/network_spec.rb
spec/integration/server_spec.rb
spec/integration/server_type_spec.rb
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@ghost ghost force-pushed the integration-tests branch 6 times, most recently from a351053 to 7523ab0 Compare January 13, 2023 13:01
@ghost
Copy link
Author

ghost commented Jan 13, 2023

@tonobo @Kjarrigan Works now, you can have a look at it when you have time. I'll leave the PR as "Draft", because before we merge I want to switch back on: push to on: workflow_dispatch. I would not want the integration test to automatically run on each push.

There are some not so nice segments in the code, maybe you know something better?

I want to allow multiple test runs in parallel, thus I am generating a unique ID. Had to use a global variable to persist it across examples :/

  def resource_name(name)
    # use a random ID to allow multiple CI runs in parallel
    $random_resource_name_id ||= Random.rand(10_000..99_999)
    "hcloud-ruby-integration-#{$random_resource_name_id}-#{name}"
  end

And some resources (floating IPs, images) do not allow easy access by name. Normally, I can delete the resources at the end of the test run by using the names, but floating IPs and images only have descriptions, so I need to delete them by ID. I am thus saving the IDs of generated resources to a instance variable @ids to be able to delete them at the end. That also feels a bit strange.

@ghost ghost marked this pull request as ready for review October 12, 2023 09:22
@ghost ghost marked this pull request as draft October 12, 2023 09:24
@ghost
Copy link
Author

ghost commented Oct 12, 2023

@tonobo Can you delete or unprotect my branch integration-tests? I can just repush it, so deletion is no problem. I rebased and want to remove the commit test integration tests within PR, so that we can merge. But Github forbids a force-push to the branch.

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.

[CI] Change fake service tests to integration tests
1 participant