Skip to content

Commit

Permalink
Launch elastic beanstalk environments for integration tests automatic…
Browse files Browse the repository at this point in the history
…ally
  • Loading branch information
tawan committed Dec 10, 2017
1 parent 440471a commit f9ea8aa
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 2 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ install:

script:
- "export EXCEPT_DEPLOYED=true"
- "if [[ $TRAVIS_PULL_REQUEST == 'false' ]]; then export EXCEPT_DEPLOYED=false; fi"
- "bundle exec rspec spec"

matrix:
Expand Down
25 changes: 25 additions & 0 deletions spec/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,33 @@ def initialize(version = "4.2")
@base_url = "https://#{WEB_ENV_HOST}/"
end

def launch_eb_environemnts
run_in_rails_app_root_dir do
unless system("./launch_eb.sh")
raise "Could not create eb environments"
end
end

end

def terminate_eb_environments
env = WEB_ENV_NAME
run_in_rails_app_root_dir do
unless system("eb terminate --force #{env}")
raise "Could not terminate environment #{env}"
end
end
env = WORKER_ENV_NAME
run_in_rails_app_root_dir do
unless system("eb terminate --force #{env}")
raise "Could not terminate environment #{env}"
end
end
end

def deploy
use_gem do
launch_eb_environemnts
deploy_to_environment(WEB_ENV_NAME)
deploy_to_environment(WORKER_ENV_NAME)
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
option_settings:
- namespace: aws:elasticbeanstalk:sqsd
option_name: WorkerQueueURL
value: https://sqs.eu-central-1.amazonaws.com/103493342764/active_elastic_job_integration_testing
6 changes: 6 additions & 0 deletions spec/integration/rails-app-4.2/launch_eb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

eb create -v -t web -s -c active-elastic-job web-env
eb create -v -t worker -s worker-env
eb setenv -e web-env SECRET_KEY_BASE=secret AWS_REGION=eu-central-1
eb setenv -e worker-env SECRET_KEY_BASE=secret AWS_REGION=eu-central-1 WEB_ENV_HOST=active-elastic-job.eu-central-1.elasticbeanstalk.com WEB_ENV_PORT=443 PROCESS_ACTIVE_ELASTIC_JOBS=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
option_settings:
- namespace: aws:elasticbeanstalk:sqsd
option_name: WorkerQueueURL
value: https://sqs.eu-central-1.amazonaws.com/103493342764/active_elastic_job_integration_testing
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
branch-defaults:
default:
environment: web-env
environment: null
group_suffix: null
global:
application_name: active_elastic_job
Expand Down
6 changes: 6 additions & 0 deletions spec/integration/rails-app-5.1/launch_eb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

eb create -v -t web -s -c active-elastic-job web-env
eb create -v -t worker -s worker-env
eb setenv -e web-env SECRET_KEY_BASE=secret AWS_REGION=eu-central-1
eb setenv -e worker-env SECRET_KEY_BASE=secret AWS_REGION=eu-central-1 WEB_ENV_HOST=active-elastic-job.eu-central-1.elasticbeanstalk.com WEB_ENV_PORT=443 PROCESS_ACTIVE_ELASTIC_JOBS=true
4 changes: 4 additions & 0 deletions spec/integration/standard_scenarios_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
@rails_app.deploy
end

after(:all) do
@rails_app.terminate_eb_environments
end

it "posts a job to the queue and processes it" do
expect(@rails_app.fetch_random_strings).to_not include(random_string)
@rails_app.create_random_string(random_string)
Expand Down

0 comments on commit f9ea8aa

Please sign in to comment.