Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

system-out is never placed under the correct testcase #175

Open
epot opened this issue Nov 2, 2023 · 2 comments
Open

system-out is never placed under the correct testcase #175

epot opened this issue Nov 2, 2023 · 2 comments

Comments

@epot
Copy link

epot commented Nov 2, 2023

I am trying to leverage this tool to send my go ci reports and logs to Datadog.

Sadly, it seems that no matter what options I try, the system-out is always put at the testsuite level, for instance:

	<testsuite name="github.com/xxx/pkg/xx" tests="1" failures="1" errors="0" id="75" hostname="stuff.local" time="5.499" timestamp="2023-11-02T09:50:29+01:00">
		<testcase name="TestDeleteSomething" classname="github.com/x/pkg/xx" time="0.000">
			<failure message="Failed"><![CDATA[    controller_test.go:289: 
        	Error Trace:	/Users/epot/ws/xxx/pkg/xx/controller_test.go:289
        	Error:      	Should be true
        	Test:       	TestDeleteSomething]]></failure>
		</testcase>
		<system-out><![CDATA[2023/11/02 09:50:24 maxprocs: Leaving GOMAXPROCS=12: CPU quota undefined]]></system-out>
	</testsuite>

Is it something not supported?

@epot
Copy link
Author

epot commented Nov 2, 2023

And as a side note (not sure if I should open a separate issue), when the test panics, all the logs is placed under error.message, like:

			<error message="No test result found"><![CDATA[
{"time":"2023-11-02T09:58:14.944416+01:00","level":"INFO","msg":"heartbeat state","git_commit":"","git_time":"0001-01-01T00:00:00Z","git_modified":false,"go_os":"","go_arch":"","process_generation":"68cbe19f-f21e-49aa-b3a7-3c1d9b991409","hostname_fqdn":"","hostname_short":"Emmanuels-MacBook-Pro.local","private_ips":["192.168.1.55","192.168.1.94"],"num_vcpus":12,"server_id":"DNS_SERVER_ID","address":"127.0.0.1:9093","module":"environment","sub_service":"environment","num_actors":0,"used_memory":0}
{"time":"2023-11-02T09:58:14.944427+01:00","level":"INFO","msg":"performed initial heartbeat","git_commit":"","git_time":"0001-01-01T00:00:00Z","git_modified":false,"go_os":"","go_arch":"","process_generation":"68cbe19f-f21e-49aa-b3a7-3c1d9b991409","hostname_fqdn":"","hostname_short":"Emmanuels-MacBook-Pro.local","private_ips":["192.168.1.55","192.168.1.94"],"num_vcpus":12,"server_id":"DNS_SERVER_ID","address":"127.0.0.1:9093","address":"127.0.0.1:9093"}
{"time":"2023-11-02T09:58:14.944475+01:00","level":"INFO","msg":"trying to connect to sqlite","git_commit":"","git_time":"0001-01-01T00:00:00Z","git_modified":false,"go_os":"","go_arch":"","process_generation":"68cbe19f-f21e-49aa-b3a7-3c1d9b991409","hostname_fqdn":"","hostname_short":"Emmanuels-MacBook-Pro.local","private_ips":["192.168.1.55","192.168.1.94"],"num_vcpus":12}
{"time":"2023-11-02T09:58:14.944671+01:00","level":"INFO","msg":"done connecting to sqlite","git_commit":"","git_time":"0001-01-01T00:00:00Z","git_modified":false,"go_os":"","go_arch":"","process_generation":"68cbe19f-f21e-49aa-b3a7-3c1d9b991409","hostname_fqdn":"","hostname_short":"Emmanuels-MacBook-Pro.local","private_ips":["192.168.1.55","192.168.1.94"],"num_vcpus":12}
....

@dkirrane
Copy link

I have similar issue:

Reproduce:

  1. Sample test
func TestPanic(t *testing.T) {
	// cause a panic in order to get the test to exit with an exception
	panic("This test has a panic")
}
  1. Run go test
go test -count=1 -v -timeout 1h | tee test_output.log
  1. Will produce test_output.log like,..
=== RUN   TestPanicTerraform
--- FAIL: TestPanicTerraform (0.00s)
panic: This test has a panic [recovered]
	panic: This test has a panic

goroutine 13 [running]:
testing.tRunner.func1.2({0x1877a80, 0x201da60})
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1548 +0x397
panic({0x1877a80?, 0x201da60?})
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/runtime/panic.go:914 +0x21f
github.com/avaya/terratest-action.TestPanicTerraform(0xc000581380?)
	/mnt/c/dev/GitHub/terratest-action/test/terraform_hello_world_test.go:117 +0x25
testing.tRunner(0xc000642680, 0x1c7e1b8)
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 1
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1648 +0x3ad
exit status 2
FAIL	github.com/company/test	0.066s

  1. Create report.xml
go-junit-report < test_output.log > report.xml

will produce

<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="6" errors="1" failures="5">
	<testsuite name="github.com/company/test" tests="6" failures="5" errors="1" id="0" hostname="foo" time="0.066" timestamp="2024-03-26T18:09:14Z">
		<testcase name="TestPanicTerraform" classname="github.com/company/test" time="0.000">
			<failure message="Failed"></failure>
		</testcase>
		<system-out><![CDATA[panic: This test has a panic [recovered]
	panic: This test has a panic

goroutine 13 [running]:
testing.tRunner.func1.2({0x1877a80, 0x201da60})
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1545 +0x238
testing.tRunner.func1()
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1548 +0x397
panic({0x1877a80?, 0x201da60?})
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/runtime/panic.go:914 +0x21f
github.com/company/test.TestPanicTerraform(0xc000581380?)
	/mnt/c/dev/GitHub/terratest-action/test/terraform_hello_world_test.go:117 +0x25
testing.tRunner(0xc000642680, 0x1c7e1b8)
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1595 +0xff
created by testing.(*T).Run in goroutine 1
	/home/linuxbrew/.linuxbrew/Cellar/go/1.21.5/libexec/src/testing/testing.go:1648 +0x3ad
exit status 2]]></system-out>
	</testsuite>
</testsuites>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants