diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e03a6ac4..6ae75c32 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -121,6 +121,22 @@ regression tests: - bundle install script: - bundle exec rake regression_tests +smoke_tests: + image: "ruby:3.3" + variables: + BUNDLE_WITHOUT: lint:assorted + CI: 1 + COVERAGE_KEY: "$RUBY_ENGINE-$RUBY_VERSION-smoke-tests" + artifacts: + paths: + - coverage/ + stage: test + before_script: + - host example.com + - apt-get update && apt-get install -y libmagic-dev shared-mime-info + - bundle install + script: + - bundle exec rake smoke_tests coverage: coverage: '/Coverage: \d+.\d+\%/' diff --git a/.rubocop.yml b/.rubocop.yml index 922fb80c..e478232f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,6 +14,7 @@ AllCops: - regression_tests/**/*.rb - integration_tests/**/*.rb - standalone_tests/**/*.rb + - smoke_tests/**/*.rb - Rakefile - httpx.gemspec - profiler/**/* diff --git a/Rakefile b/Rakefile index 50b8e83f..ace72150 100644 --- a/Rakefile +++ b/Rakefile @@ -24,6 +24,13 @@ Rake::TestTask.new(:regression_tests) do |t| t.warning = false end +desc "smoke tests for core features not in main tests" +Rake::TestTask.new(:smoke_tests) do |t| + t.libs = %w[lib test] + t.pattern = "smoke_tests/**/*_test.rb" + t.warning = false +end + RUBY_MAJOR_MINOR = RUBY_VERSION.split(".").first(2).join(".") begin diff --git a/smoke_tests/happy_eyeballs_test.rb b/smoke_tests/happy_eyeballs_test.rb new file mode 100644 index 00000000..c50e5ca0 --- /dev/null +++ b/smoke_tests/happy_eyeballs_test.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require "test_helper" +require "support/http_helpers" + +# https://test-ipv6.com/ +class HappyEyeballsTest < Minitest::Test + include HTTPHelpers + + IPV6_HOST = "https://ipv6.test-ipv6.com" + IPV4_HOST = "https://ipv4.test-ipv6.com" + + def test_happy_eyeballs_prefer_ipv6 + response = HTTPX.get(IPV6_HOST) + verify_status(response, 200) + peer_address = response.peer_address + assert peer_address.ipv6? + end + + def test_happy_eyeballs_prefer_ipv4 + response = HTTPX.get(IPV4_HOST) + verify_status(response, 200) + peer_address = response.peer_address + assert peer_address.ipv4? + end +end