Unverified Commit 0a06946f authored by Jeremy Morrell's avatar Jeremy Morrell Committed by GitHub

Hatchet tests (#552)

Adds hatchet tests as part of our testing matrix and adds that to Travis CI
parent eb4b411e
......@@ -3,8 +3,12 @@ sudo: required
services:
- docker
env:
- STACK=heroku-18
- STACK=heroku-16
- STACK=cedar-14
install: docker pull "heroku/${STACK/-/:}"
script: make test-${STACK}
- TEST=heroku-18 STACK=heroku-18
- TEST=heroku-16 STACK=heroku-16
- TEST=cedar-14 STACK=cedar-14
- TEST=hatchet
install:
- if [[ -n $STACK ]]; then
docker pull "heroku/${STACK/-/:}";
fi
script: make ${TEST}
source "https://rubygems.org"
gem 'heroku_hatchet', :git => 'https://github.com/heroku/hatchet.git', :branch => 'support-local-directories-for-fixtures'
gem 'rspec-retry'
gem 'rspec-expectations'
gem 'sem_version'
gem "parallel_tests"
gem "rake"
GIT
remote: https://github.com/heroku/hatchet.git
revision: 4ea40af89e00d49dd21f9695ce99f21219a0455b
branch: support-local-directories-for-fixtures
specs:
heroku_hatchet (4.0.4)
excon (~> 0)
minitest-retry (~> 0.1.9)
platform-api (~> 2)
repl_runner (~> 0.0.3)
rrrretry (~> 1)
thor (~> 0)
threaded (~> 0)
GEM
remote: https://rubygems.org/
specs:
activesupport (5.2.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
concurrent-ruby (1.0.5)
diff-lcs (1.3)
erubis (2.7.0)
excon (0.62.0)
heroics (0.0.24)
erubis (~> 2.0)
excon
moneta
multi_json (>= 1.9.2)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
minitest-retry (0.1.9)
minitest (>= 5.0)
moneta (0.8.1)
multi_json (1.13.1)
parallel (1.12.1)
parallel_tests (2.22.0)
parallel
platform-api (2.1.0)
heroics (~> 0.0.23)
moneta (~> 0.8.1)
rake (12.3.1)
repl_runner (0.0.3)
activesupport
rrrretry (1.0.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-retry (0.6.1)
rspec-core (> 3.3)
rspec-support (3.8.0)
sem_version (2.0.1)
thor (0.20.0)
thread_safe (0.3.6)
threaded (0.0.4)
tzinfo (1.2.5)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
heroku_hatchet!
parallel_tests
rake
rspec-expectations
rspec-retry
sem_version
BUNDLED WITH
1.16.4
#!/usr/bin/env bash
[ "$CI" != "true" ] && echo "Not running on CI!" && exit 1
git config --global user.email ${HEROKU_API_USER:-"buildpack@example.com"}
git config --global user.name 'BuildpackTester'
cat <<EOF >> ~/.ssh/config
Host heroku.com
StrictHostKeyChecking no
CheckHostIP no
UserKnownHostsFile=/dev/null
Host github.com
StrictHostKeyChecking no
EOF
cat <<EOF >> ~/.netrc
machine git.heroku.com
login ${HEROKU_API_USER:-"buildpack@example.com"}
password ${HEROKU_API_KEY:-"password"}
EOF
sudo apt-get -qq update
sudo apt-get install software-properties-common -y
curl --fail --retry 3 --retry-delay 1 --connect-timeout 3 --max-time 30 https://cli-assets.heroku.com/install-ubuntu.sh | sh
if [ -n "$HEROKU_API_KEY" ]; then
yes | heroku keys:add
fi
#!/usr/bin/env bash
set -e
if [ "$CIRCLECI" == "true" ] && [ -n "$CI_PULL_REQUEST" ]; then
if [ "$CIRCLE_PR_USERNAME" != "heroku" ]; then
echo "Skipping integration tests on forked PR."
exit 0
fi
fi
if [ "$TRAVIS" == "true" ] && [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
if [ "$TRAVIS_PULL_REQUEST_SLUG" != "heroku/heroku-buildpack-nodejs" ]; then
echo "Skipping integration tests on forked PR."
exit 0
fi
fi
if [ -z "$HEROKU_API_KEY" ]; then
echo "ERROR: Missing \$HEROKU_API_KEY."
exit 1
fi
if [ -n "$CIRCLE_BRANCH" ]; then
export HATCHET_BUILDPACK_BRANCH="$CIRCLE_BRANCH"
elif [ -n "$TRAVIS_PULL_REQUEST_BRANCH" ]; then
export IS_RUNNING_ON_TRAVIS=true
export HATCHET_BUILDPACK_BRANCH="$TRAVIS_PULL_REQUEST_BRANCH"
else
export HATCHET_BUILDPACK_BRANCH=$(git name-rev HEAD 2> /dev/null | sed 's#HEAD\ \(.*\)#\1#')
fi
gem install bundler
bundle install
export HATCHET_RETRIES=3
export HATCHET_APP_LIMIT=20
export HATCHET_DEPLOY_STRATEGY=git
export HATCHET_BUILDPACK_BASE="https://github.com/heroku/heroku-buildpack-nodejs"
bundle exec rspec "$@"
test: test-heroku-18 test-heroku-16 test-cedar-14
test: heroku-18 heroku-16 cedar-14
test-heroku-18:
heroku-18:
@echo "Running tests in docker (heroku-18)..."
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-18" heroku/heroku:18 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;'
@echo ""
test-heroku-16:
heroku-16:
@echo "Running tests in docker (heroku-16)..."
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-16" heroku/heroku:16 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;'
@echo ""
test-cedar-14:
cedar-14:
@echo "Running tests in docker (cedar-14)..."
@docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=cedar-14" heroku/cedar:14 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;'
@echo ""
hatchet:
@echo "Running hatchet integration tests"
bash etc/ci-setup.sh
bash etc/hatchet.sh
@echo ""
shell:
@echo "Opening heroku-16 shell..."
@docker run -v $(shell pwd):/buildpack:ro --rm -it heroku/heroku:16 bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; bash'
......
require_relative 'spec_helper'
describe "Node Metrics for v10.x" do
context "test metrics for Node v10.x app" do
let(:app) {
Hatchet::Runner.new(
"spec/fixtures/repos/node-10-metrics",
config: {
"HEROKU_METRICS_URL" => "http://localhost:3000",
"METRICS_INTERVAL_OVERRIDE" => "10000"
}
)
}
it "should deploy" do
app.deploy do |app|
data = successful_json_body(app)
expect(data["gauges"]["node.eventloop.delay.ms.max"]).to be >= 2000
expect(data["counters"]["node.gc.collections"]).to be >= 0
expect(data["counters"]["node.gc.young.collections"]).to be >= 0
expect(data["counters"]["node.gc.old.collections"]).to be >= 0
end
end
end
end
require_relative 'spec_helper'
describe "Hello World for Node v10.x" do
context "a single-process Node v10.x app" do
let(:app) {
Hatchet::Runner.new("spec/fixtures/repos/node-10")
}
it "should deploy successfully" do
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello, world!")
end
end
end
end
require_relative 'spec_helper'
describe "Hello World for Node v6.x" do
context "a single-process Node v6.x app" do
let(:app) {
Hatchet::Runner.new("spec/fixtures/repos/node-6")
}
it "should deploy successfully" do
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello, world!")
end
end
end
end
require_relative 'spec_helper'
describe "Node Metrics for v8.x" do
context "test metrics for Node v8.x app" do
let(:app) {
Hatchet::Runner.new(
"spec/fixtures/repos/node-8-metrics",
config: {
"HEROKU_METRICS_URL" => "http://localhost:3000",
"METRICS_INTERVAL_OVERRIDE" => "10000"
}
)
}
it "should deploy" do
app.deploy do |app|
data = successful_json_body(app)
expect(data["gauges"]["node.eventloop.delay.ms.max"]).to be >= 2000
expect(data["counters"]["node.gc.collections"]).to be >= 0
expect(data["counters"]["node.gc.young.collections"]).to be >= 0
expect(data["counters"]["node.gc.old.collections"]).to be >= 0
end
end
end
end
require_relative 'spec_helper'
describe "Hello World for Node v8.x" do
context "a single-process Node v8.x app" do
let(:app) {
Hatchet::Runner.new(
"spec/fixtures/repos/node-8"
)
}
it "should deploy successfully" do
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello, world!")
end
end
end
end
require_relative 'spec_helper'
describe "Node Metrics for v9.x" do
context "test metrics for Node v9.x app" do
let(:app) {
Hatchet::Runner.new(
"spec/fixtures/repos/node-9-metrics",
config: {
"HEROKU_METRICS_URL" => "http://localhost:3000",
"METRICS_INTERVAL_OVERRIDE" => "10000"
}
)
}
it "should deploy" do
app.deploy do |app|
data = successful_json_body(app)
expect(data["gauges"]["node.eventloop.delay.ms.max"]).to be >= 2000
expect(data["counters"]["node.gc.collections"]).to be >= 0
expect(data["counters"]["node.gc.young.collections"]).to be >= 0
expect(data["counters"]["node.gc.old.collections"]).to be >= 0
end
end
end
end
require_relative 'spec_helper'
describe "Hello World for Node v9.x" do
context "a single-process Node v9.x app" do
let(:app) {
Hatchet::Runner.new("spec/fixtures/repos/node-9")
}
it "should deploy successfully" do
app.deploy do |app|
expect(successful_body(app).strip).to eq("Hello, world!")
end
end
end
end
require 'rspec/core'
require 'hatchet'
require 'fileutils'
require 'hatchet'
require 'rspec/retry'
require 'date'
require 'json'
require 'sem_version'
ENV['RACK_ENV'] = 'test'
RSpec.configure do |config|
config.filter_run focused: true unless ENV['IS_RUNNING_ON_TRAVIS']
config.run_all_when_everything_filtered = true
config.alias_example_to :fit, focused: true
config.full_backtrace = true
config.verbose_retry = true # show retry status in spec process
config.default_retry_count = 2 if ENV['IS_RUNNING_ON_TRAVIS'] # retry all tests that fail again
config.expect_with :rspec do |c|
c.syntax = :expect
end
end
def successful_body(app, options = {})
retry_limit = options[:retry_limit] || 100
path = options[:path] ? "/#{options[:path]}" : ''
Excon.get("http://#{app.name}.herokuapp.com#{path}", :idempotent => true, :expects => 200, :retry_limit => retry_limit).body
end
def successful_json_body(app, options = {})
body = successful_body(app, options)
JSON.parse(body)
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment