-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
junit: fix xml.Name for testsuite properties
TestSuite properties should be `properties` not `property`, we can't unmarshal some junits in the job run uploader currently, it errors out like this: ``` time="2022-07-06T08:01:16Z" level=fatal msg="Command failed" error="[jobrun/release-openshift-ocp-osd-aws-nightly-4.11/1544457393197289472 failed to upload to bigquery: error parsing junit for jobrun/release-openshift-ocp-osd-aws-nightly-4.11/1544457393197289472 \"logs/release-openshift-ocp-osd-aws-nightly-4.11/1544457393197289472/artifacts/install/junit_0zg9j.xml\": testsuiteError=expected element type <testsuite> but have <testsuites> testsuitesError=expected element type <property> but have <properties>, jobrun/release-openshift-ocp-osd-aws-nightly-4.10/1544448209282142208 failed to upload to bigquery: error parsing junit for jobrun/release-openshift-ocp-osd-aws-nightly-4.10/1544448209282142208 \"logs/release-openshift-ocp-osd-aws-nightly-4.10/1544448209282142208/artifacts/install/junit_a75tc.xml\": testsuiteError=expected element type <testsuite> but have <testsuites> testsuitesError=expected element type <property> but have <properties>, jobrun/release-openshift-ocp-osd-gcp-nightly-4.10/154444821514... ``` Per the confusing xml docs[1], we can use the `>` operator to indicate sub-elements: ``` If the XML element contains a sub-element whose name matches the prefix of a tag formatted as "a" or "a>b>c", unmarshal will descend into the XML structure looking for elements with the given names, and will map the innermost elements to that struct field. A tag starting with ">" is equivalent to one starting with the field name followed by ">". ``` [1] https://pkg.go.dev/encoding/xml
- Loading branch information
Showing
6 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package junit | ||
|
||
import ( | ||
"encoding/xml" | ||
"testing" | ||
) | ||
|
||
const junitXML = `<testsuites> | ||
<testsuite tests="1" failures="0" time="1983" name=""> | ||
<properties> | ||
<property name="go.version" value="go1.17.5 linux/amd64"/> | ||
</properties> | ||
<testcase classname="" name="TestUpgradeControlPlane" time="1983"/> | ||
</testsuite> | ||
</testsuites>` | ||
|
||
func Test_CanUnmarshalTestSuites(t *testing.T) { | ||
suites := &TestSuites{} | ||
if err := xml.Unmarshal([]byte(junitXML), suites); err != nil { | ||
t.Fatalf("could not unmarshal: %s", err.Error()) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test/e2e/observer/artifacts/failing-observer-junit_operator.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters