Skip to content

Commit 20886bc

Browse files
authored
Merge pull request #4372 from DataDog/tonycthsu/test-agent-enable
Run test agent check in Github Actions
2 parents 47ef2d0 + 3d817fa commit 20886bc

File tree

5 files changed

+72
-43
lines changed

5 files changed

+72
-43
lines changed

Diff for: .circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ step_get_test_agent_trace_check_results: &step_get_test_agent_trace_check_result
101101
run:
102102
name: Get APM Test Agent Trace Check Results
103103
command: |
104-
ruby .circleci/test_agent_check.rb
104+
ruby .github/scripts/test_agent_check.rb
105105
when: always
106106

107107
filters_all_branches_and_tags: &filters_all_branches_and_tags

Diff for: .circleci/test_agent_check.rb

-42
This file was deleted.

Diff for: .github/scripts/test_agent_check.rb

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env ruby
2+
3+
require "net/http"
4+
require "uri"
5+
require "json"
6+
7+
# Disable exiting on command failure
8+
agent_host = ENV["DD_AGENT_HOST"] || raise("DD_AGENT_HOST is not set")
9+
agent_port = ENV["DD_TRACE_AGENT_PORT"] || raise("DD_TRACE_AGENT_PORT is not set")
10+
11+
begin
12+
# Check if test agent is running
13+
summary_uri = URI.parse("http://#{agent_host}:#{agent_port}/test/trace_check/summary")
14+
summary_response = Net::HTTP.get_response(summary_uri)
15+
16+
if summary_response.code == "200"
17+
puts "APM Test Agent is running. (HTTP 200)"
18+
else
19+
puts "APM Test Agent is not running and was not used for testing. No checks failed."
20+
exit 0
21+
end
22+
23+
# Check for test failures
24+
failures_uri = URI.parse("http://#{agent_host}:#{agent_port}/test/trace_check/failures")
25+
failures_response = Net::HTTP.get_response(failures_uri)
26+
27+
case failures_response.code
28+
when "200"
29+
puts "All APM Test Agent Check Traces returned successful! (HTTP 200)"
30+
puts "APM Test Agent Check Traces Summary Results:"
31+
puts JSON.pretty_generate(JSON.parse(summary_response.body))
32+
when "404"
33+
puts "Real APM Agent running in place of TestAgent, no checks to validate!"
34+
else
35+
puts "APM Test Agent Check Traces failed with response code: #{failures_response.code}"
36+
puts "Failures:"
37+
puts failures_response.body
38+
puts "APM Test Agent Check Traces Summary Results:"
39+
puts JSON.pretty_generate(JSON.parse(summary_response.body))
40+
exit 1
41+
end
42+
rescue => e
43+
puts "An error occurred: #{e.message}"
44+
exit 1
45+
end

Diff for: .github/workflows/test.yml

+22
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ jobs:
145145
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
146146
with:
147147
limit-access-to-actor: true
148+
- if: always()
149+
run: ruby .github/scripts/test_agent_check.rb
148150
- if: always()
149151
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
150152
with:
@@ -280,6 +282,8 @@ jobs:
280282
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
281283
with:
282284
limit-access-to-actor: true
285+
- if: always()
286+
run: ruby .github/scripts/test_agent_check.rb
283287
- if: always()
284288
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
285289
with:
@@ -415,6 +419,8 @@ jobs:
415419
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
416420
with:
417421
limit-access-to-actor: true
422+
- if: always()
423+
run: ruby .github/scripts/test_agent_check.rb
418424
- if: always()
419425
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
420426
with:
@@ -550,6 +556,8 @@ jobs:
550556
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
551557
with:
552558
limit-access-to-actor: true
559+
- if: always()
560+
run: ruby .github/scripts/test_agent_check.rb
553561
- if: always()
554562
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
555563
with:
@@ -685,6 +693,8 @@ jobs:
685693
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
686694
with:
687695
limit-access-to-actor: true
696+
- if: always()
697+
run: ruby .github/scripts/test_agent_check.rb
688698
- if: always()
689699
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
690700
with:
@@ -820,6 +830,8 @@ jobs:
820830
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
821831
with:
822832
limit-access-to-actor: true
833+
- if: always()
834+
run: ruby .github/scripts/test_agent_check.rb
823835
- if: always()
824836
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
825837
with:
@@ -955,6 +967,8 @@ jobs:
955967
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
956968
with:
957969
limit-access-to-actor: true
970+
- if: always()
971+
run: ruby .github/scripts/test_agent_check.rb
958972
- if: always()
959973
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
960974
with:
@@ -1090,6 +1104,8 @@ jobs:
10901104
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
10911105
with:
10921106
limit-access-to-actor: true
1107+
- if: always()
1108+
run: ruby .github/scripts/test_agent_check.rb
10931109
- if: always()
10941110
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
10951111
with:
@@ -1225,6 +1241,8 @@ jobs:
12251241
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
12261242
with:
12271243
limit-access-to-actor: true
1244+
- if: always()
1245+
run: ruby .github/scripts/test_agent_check.rb
12281246
- if: always()
12291247
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
12301248
with:
@@ -1360,6 +1378,8 @@ jobs:
13601378
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
13611379
with:
13621380
limit-access-to-actor: true
1381+
- if: always()
1382+
run: ruby .github/scripts/test_agent_check.rb
13631383
- if: always()
13641384
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
13651385
with:
@@ -1495,6 +1515,8 @@ jobs:
14951515
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
14961516
with:
14971517
limit-access-to-actor: true
1518+
- if: always()
1519+
run: ruby .github/scripts/test_agent_check.rb
14981520
- if: always()
14991521
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
15001522
with:

Diff for: tasks/github.rake

+4
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ namespace :github do
225225
'limit-access-to-actor' => true,
226226
}
227227
},
228+
{
229+
'if' => 'always()',
230+
'run' => 'ruby .github/scripts/test_agent_check.rb'
231+
},
228232
{
229233
'if' => 'always()',
230234
'uses' => 'actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08',

0 commit comments

Comments
 (0)