WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f3ad82a

Browse files
committed
Run http_request test only 1 build in each pipeline
This repository uses matrix to run 50+ builds in a pipeline. This results in simultaneous requests being sent to httpbin.org, similar to a DDoS attack, often causing 500 errors and test failures. e.g. https://github.com/itamae-kitchen/itamae/actions/runs/17045210601/job/48319099479?pr=379 Therefore, I suppressed simultaneous requests to httpbin.org.
1 parent 2766b2b commit f3ad82a

File tree

7 files changed

+78
-58
lines changed

7 files changed

+78
-58
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ jobs:
6767
with:
6868
ruby: ${{ matrix.ruby }}
6969
rubyopt: ${{ matrix.rubyopt }}
70+
71+
# This repository uses matrix to run 50+ builds in a pipeline.
72+
# This results in simultaneous requests being sent to httpbin.org,
73+
# similar to a DDoS attack, often causing 500 errors and test failures.
74+
#
75+
# e.g. https://github.com/itamae-kitchen/itamae/actions/runs/17045210601/job/48319099479?pr=379
76+
#
77+
# Therefore, I suppressed simultaneous requests to httpbin.org.
78+
skip_http_request_test: ${{ (matrix.ruby == '2.3' && matrix.rubyopt == '') && 'false' || 'true' }}
7079
secrets:
7180
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
7281

.github/workflows/test_main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
required: false
1111
type: string
1212
default: ""
13+
skip_http_request_test:
14+
required: true
15+
type: string
1316
secrets:
1417
SLACK_WEBHOOK:
1518
required: true
@@ -72,6 +75,7 @@ jobs:
7275
- run: bundle exec rake spec:integration:docker:boot
7376
env:
7477
RUBYOPT: ${{ inputs.rubyopt }}
78+
SKIP_HTTP_REQUEST_TEST: ${{ inputs.skip_http_request_test }}
7579

7680
- run: bundle exec rake spec:integration:docker:provision
7781
env:
@@ -83,6 +87,7 @@ jobs:
8387
- run: bundle exec rake spec:integration:docker:serverspec
8488
env:
8589
RUBYOPT: ${{ inputs.rubyopt }}
90+
SKIP_HTTP_REQUEST_TEST: ${{ inputs.skip_http_request_test }}
8691

8792
- run: bundle exec rake spec:integration:docker:clean_docker_container
8893
env:
@@ -120,10 +125,12 @@ jobs:
120125
- run: bundle exec rake spec:integration:local:main
121126
env:
122127
RUBYOPT: ${{ inputs.rubyopt }}
128+
SKIP_HTTP_REQUEST_TEST: ${{ inputs.skip_http_request_test }}
123129

124130
- run: bundle exec rake spec:integration:local:ordinary_user
125131
env:
126132
RUBYOPT: ${{ inputs.rubyopt }}
133+
SKIP_HTTP_REQUEST_TEST: ${{ inputs.skip_http_request_test }}
127134

128135
# TODO: for develop
129136
# - name: Slack Notification (not success)

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace :spec do
2929
namespace :docker do
3030
desc "Run docker"
3131
task :boot do
32-
sh "docker run --privileged -d --name #{container_name} #{TEST_IMAGE} /sbin/init"
32+
sh "docker run --env SKIP_HTTP_REQUEST_TEST --privileged -d --name #{container_name} #{TEST_IMAGE} /sbin/init"
3333
end
3434

3535
desc "Run itamae"

spec/integration/default_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,34 +77,34 @@
7777
it { should_not be_file }
7878
end
7979

80-
describe file('/tmp/http_request.html') do
80+
describe file('/tmp/http_request.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
8181
it { should be_file }
8282
its(:content) { should match(/"from":\s*"itamae"/) }
8383
end
8484

85-
describe file('/tmp/http_request_delete.html') do
85+
describe file('/tmp/http_request_delete.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
8686
it { should be_file }
8787
its(:content) { should match(/"from":\s*"itamae"/) }
8888
end
8989

90-
describe file('/tmp/http_request_post.html') do
90+
describe file('/tmp/http_request_post.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
9191
it { should be_file }
9292
its(:content) { should match(/"from":\s*"itamae"/) }
9393
its(:content) { should match(/"love":\s*"sushi"/) }
9494
end
9595

96-
describe file('/tmp/http_request_put.html') do
96+
describe file('/tmp/http_request_put.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
9797
it { should be_file }
9898
its(:content) { should match(/"from":\s*"itamae"/) }
9999
its(:content) { should match(/"love":\s*"sushi"/) }
100100
end
101101

102-
describe file('/tmp/http_request_headers.html') do
102+
describe file('/tmp/http_request_headers.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
103103
it { should be_file }
104104
its(:content) { should match(/"User-Agent":\s*"Itamae"/) }
105105
end
106106

107-
xdescribe file('/tmp/http_request_redirect.html') do
107+
xdescribe file('/tmp/http_request_redirect.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
108108
it { should be_file }
109109
its(:content) { should match(/"from":\s*"itamae"/) }
110110
end

spec/integration/ordinary_user_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,22 @@
8484

8585
###
8686

87-
describe file('/tmp/http_request.html') do
87+
describe file('/tmp/http_request.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
8888
it { should be_file }
8989
it { should be_owned_by "ordinary_san" }
9090
it { should be_grouped_into "ordinary_san" }
9191
its(:content) { should match(/"from":\s*"itamae"/) }
9292
end
9393

94-
describe file('/tmp/http_request_root.html') do
94+
describe file('/tmp/http_request_root.html'), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
9595
it { should be_file }
9696
it { should be_owned_by "root" }
9797
it { should be_grouped_into "root" }
9898
its(:content) { should match(/"from":\s*"itamae"/) }
9999
end
100100

101101
%w[/tmp/http_request_another_ordinary.html /tmp/http_request_another_ordinary_with_root.html].each do |path|
102-
describe file(path) do
102+
describe file(path), unless: ENV["SKIP_HTTP_REQUEST_TEST"] == "true" do
103103
it { should be_file }
104104
it { should be_owned_by "itamae" }
105105
it { should be_grouped_into "itamae" }

spec/integration/recipes/default.rb

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -192,36 +192,38 @@
192192

193193
######
194194

195-
http_request "/tmp/http_request.html" do
196-
url "https://httpbin.org/get?from=itamae"
197-
end
195+
unless ENV["SKIP_HTTP_REQUEST_TEST"] == "true"
196+
http_request "/tmp/http_request.html" do
197+
url "https://httpbin.org/get?from=itamae"
198+
end
198199

199-
http_request "/tmp/http_request_delete.html" do
200-
action :delete
201-
url "https://httpbin.org/delete?from=itamae"
202-
end
200+
http_request "/tmp/http_request_delete.html" do
201+
action :delete
202+
url "https://httpbin.org/delete?from=itamae"
203+
end
203204

204-
http_request "/tmp/http_request_post.html" do
205-
action :post
206-
message "love=sushi"
207-
url "https://httpbin.org/post?from=itamae"
208-
end
205+
http_request "/tmp/http_request_post.html" do
206+
action :post
207+
message "love=sushi"
208+
url "https://httpbin.org/post?from=itamae"
209+
end
209210

210-
http_request "/tmp/http_request_put.html" do
211-
action :put
212-
message "love=sushi"
213-
url "https://httpbin.org/put?from=itamae"
214-
end
211+
http_request "/tmp/http_request_put.html" do
212+
action :put
213+
message "love=sushi"
214+
url "https://httpbin.org/put?from=itamae"
215+
end
215216

216-
http_request "/tmp/http_request_headers.html" do
217-
headers "User-Agent" => "Itamae"
218-
url "https://httpbin.org/get"
219-
end
217+
http_request "/tmp/http_request_headers.html" do
218+
headers "User-Agent" => "Itamae"
219+
url "https://httpbin.org/get"
220+
end
220221

221-
# http_request "/tmp/http_request_redirect.html" do
222-
# redirect_limit 1
223-
# url "https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org%2Fget%3Ffrom%3Ditamae"
224-
# end
222+
# http_request "/tmp/http_request_redirect.html" do
223+
# redirect_limit 1
224+
# url "https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org%2Fget%3Ffrom%3Ditamae"
225+
# end
226+
end
225227

226228
link "/tmp-link" do
227229
to "/tmp"

spec/integration/recipes/ordinary_user.rb

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -83,27 +83,29 @@
8383

8484
###
8585

86-
http_request "/tmp/http_request.html" do
87-
url "https://httpbin.org/get?from=itamae"
88-
end
89-
90-
http_request "/tmp/http_request_root.html" do
91-
user 'root'
92-
owner 'root'
93-
group 'root'
94-
url "https://httpbin.org/get?from=itamae"
95-
end
96-
97-
http_request "/tmp/http_request_another_ordinary.html" do
98-
user 'itamae'
99-
owner 'itamae'
100-
group 'itamae'
101-
url "https://httpbin.org/get?from=itamae"
102-
end
103-
104-
http_request "/tmp/http_request_another_ordinary_with_root.html" do
105-
user 'root'
106-
owner 'itamae'
107-
group 'itamae'
108-
url "https://httpbin.org/get?from=itamae"
86+
unless ENV["SKIP_HTTP_REQUEST_TEST"] == "true"
87+
http_request "/tmp/http_request.html" do
88+
url "https://httpbin.org/get?from=itamae"
89+
end
90+
91+
http_request "/tmp/http_request_root.html" do
92+
user 'root'
93+
owner 'root'
94+
group 'root'
95+
url "https://httpbin.org/get?from=itamae"
96+
end
97+
98+
http_request "/tmp/http_request_another_ordinary.html" do
99+
user 'itamae'
100+
owner 'itamae'
101+
group 'itamae'
102+
url "https://httpbin.org/get?from=itamae"
103+
end
104+
105+
http_request "/tmp/http_request_another_ordinary_with_root.html" do
106+
user 'root'
107+
owner 'itamae'
108+
group 'itamae'
109+
url "https://httpbin.org/get?from=itamae"
110+
end
109111
end

0 commit comments

Comments
 (0)