-
Notifications
You must be signed in to change notification settings - Fork 78
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
[USDU-407] Add automated tests for Analytics #398
base: dev
Are you sure you want to change the base?
Conversation
Are you aware the tests are failing on 2023.1 and newer?
|
… version to be 2023.2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions. Looks like tests are still failing on trunk.
} | ||
catch | ||
{ | ||
Debug.Log("Artifact Clean up has failed - This should not happen in most cases, but even if so, the test case should not be affected."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we feed back further detail on the failure by also logging the exception?
package/com.unity.formats.usd/Tests/Editor/EditorAnalyticsBaseFixture.cs
Outdated
Show resolved
Hide resolved
…om the manifest.json | Adds analytics to the formats.usd package
Requires Mike's fixes: Link |
… version to be 2023.2
…om the manifest.json | Adds analytics to the formats.usd package
…ies/usd-unity-sdk into AddAnalyticsTest # Conflicts: # package/com.unity.formats.usd/Tests/Common/BaseFixture.cs # package/com.unity.formats.usd/Tests/Common/Data/Material/Invalid.format # package/com.unity.formats.usd/Tests/Common/Data/Material/Invalid.format.meta # package/com.unity.formats.usd/Tests/Common/Data/Material/InvalidContent.usda # package/com.unity.formats.usd/Tests/Common/Data/Material/InvalidContent.usda.meta # package/com.unity.formats.usd/Tests/Common/Data/Material/Kiki_Blendshape.usd # package/com.unity.formats.usd/Tests/Common/Data/Material/Kiki_Blendshape.usd.meta # package/com.unity.formats.usd/Tests/Editor/EditorAnalyticsBaseFixture.cs # package/com.unity.formats.usd/Tests/Editor/EditorExportAnalyticsTests.cs # package/com.unity.formats.usd/Tests/Editor/EditorExportAnalyticsTests.cs.meta # package/com.unity.formats.usd/Tests/Editor/EditorImportAnalyticsTests.cs # package/com.unity.formats.usd/Tests/Editor/EditorImportAnalyticsTests.cs.meta # package/com.unity.formats.usd/Tests/Editor/EditorReImportAnalyticsTests.cs # package/com.unity.formats.usd/Tests/Editor/EditorReImportAnalyticsTests.cs.meta # package/com.unity.formats.usd/Tests/Editor/Unity.Formats.USD.Tests.Editor.asmdef
.yamato/package-test.yml
Outdated
@@ -13,7 +13,11 @@ test_{{ platform.name }}_{{ editor.version }}: | |||
UPMCI_PKG: "upm-ci-utils@stable" | |||
commands: | |||
- npm install {% if platform.name == "win" %}"%UPMCI_PKG%"{% else %}"$UPMCI_PKG"{% endif %} -g --registry {{ registry.npm }} | |||
- upm-ci package test -u {{ editor.version }} --package-path package/com.unity.formats.usd --type package-tests --extra-utr-arg="--api-profile=NET_4_6" | |||
{% if editor.version == "trunk" %} | |||
- upm-ci package test -u {{ editor.version }} --package-path package/com.unity.formats.usd --type package-tests --extra-utr-arg="--api-profile=NET_4_6" --extra-editor-arg=-editorAnalyticsTestMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is behind an if statement as there was a bug in the analytics side where if this was set for versions less than trunk, it would crash the editor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should specify 'trunk' here as it isn't robust for the future. Eventually trunk will be newer that 2023 and the '23 LTS won't be tested/ the tests will run without this editor arg being set. I'm not sure what the correct answer is though :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small fixes and clean up suggested, but otherwise good so far!
@@ -1,11 +1,12 @@ | |||
{ | |||
"dependencies": { | |||
"com.unity.analytics": "3.5.3", | |||
"com.unity.editor-analytics-debugger": "0.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ok in 2019.4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this is leftover from when I initially started the review 😂
.yamato/package-test.yml
Outdated
@@ -13,7 +13,11 @@ test_{{ platform.name }}_{{ editor.version }}: | |||
UPMCI_PKG: "upm-ci-utils@stable" | |||
commands: | |||
- npm install {% if platform.name == "win" %}"%UPMCI_PKG%"{% else %}"$UPMCI_PKG"{% endif %} -g --registry {{ registry.npm }} | |||
- upm-ci package test -u {{ editor.version }} --package-path package/com.unity.formats.usd --type package-tests --extra-utr-arg="--api-profile=NET_4_6" | |||
{% if editor.version == "trunk" %} | |||
- upm-ci package test -u {{ editor.version }} --package-path package/com.unity.formats.usd --type package-tests --extra-utr-arg="--api-profile=NET_4_6" --extra-editor-arg=-editorAnalyticsTestMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should specify 'trunk' here as it isn't robust for the future. Eventually trunk will be newer that 2023 and the '23 LTS won't be tested/ the tests will run without this editor arg being set. I'm not sure what the correct answer is though :)
.yamato/package-test.yml
Outdated
@@ -13,7 +13,11 @@ test_{{ platform.name }}_{{ editor.version }}: | |||
UPMCI_PKG: "upm-ci-utils@stable" | |||
commands: | |||
- npm install {% if platform.name == "win" %}"%UPMCI_PKG%"{% else %}"$UPMCI_PKG"{% endif %} -g --registry {{ registry.npm }} | |||
- upm-ci package test -u {{ editor.version }} --package-path package/com.unity.formats.usd --type package-tests --extra-utr-arg="--api-profile=NET_4_6" | |||
{% if editor.version == "trunk" %} | |||
- upm-ci package test -u {{ editor.version }} --package-path package/com.unity.formats.usd --type package-tests --extra-utr-arg="--api-profile=NET_4_6" --extra-editor-arg=-editorAnalyticsTestMode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does the --extra-editor-arg=-editorAnalyticsTestMode
alleviate the need for UNITY_THISISABUILDMACHINE? ie does it set the runmode to test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized i set the "UNITY_THISISABUILDMACHINE" but it never got passed over to the yamato call, and i believe our test machines already have the "UNITY_THISISABUILDMACHINE" set to true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see what is included here, but it's quite a big asset to include for the sake of a test, and I'm also not sure whether it can be shared publicly in this way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats a good point, i just needed an invalid USD file for a failure, in this case blendshapes, i'll look for another asset
InitUsd.Initialize(); | ||
} | ||
|
||
public IEnumerator WaitForUsdAnalytics<T>(string expectedType, System.Action<AnalyticsEvent> expectedEvent, float attemptFrameCountLimit = 300) where T: UsdAnalyticsEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This frame count limit is very high- are you sure it needs to be this high?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to use c#'s stopwatch for shorter + more accurate measurement
public UsdAnalyticsEvent usd; | ||
} | ||
|
||
public class SharedAnalyticsEvent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shared event is no longer used anywhere- can it be removed now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case can we remove a layer of abstraction and use the UsdAnalyticsEvent directly instead of the AnalyticsEvent wrapper? To simplify lines like var exportUsdEventMsg = ((UsdAnalyticsEventExport)exportEvent.usd).msg;
a bit, as they're hard to parse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for eg var exportUsdEventMsg = ((UsdAnalyticsEventExport)exportEvent).eventData;
in that case would be easier to reason at a glance what it's getting
Assert.IsNotNull(exportEvent); | ||
var exportUsdEventMsg = ((UsdAnalyticsEventExport)exportEvent.usd).msg; | ||
|
||
Assert.IsTrue(exportUsdEventMsg.Succeeded, "Expected True for re-import Successful"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
think this should be 'export successful'
Assert.IsNotNull(exportEvent); | ||
var exportUsdEventMsg = ((UsdAnalyticsEventExport)exportEvent.usd).msg; | ||
|
||
Assert.IsTrue(exportUsdEventMsg.Succeeded, "Expected True for re-import Successful"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above :)
Assert.IsNotNull(exportEvent); | ||
var exportUsdEventMsg = ((UsdAnalyticsEventExport)exportEvent.usd).msg; | ||
|
||
Assert.IsFalse(exportUsdEventMsg.Succeeded, "Expected Fail for re-import Successful"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above :)
|
||
public class UsdAnalyticsEvent | ||
{ | ||
public string type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I understanding correctly that this actually stores the event name string eg editor.USDFileImport
, or is it actually the C# type name of the event? If it is the former I'd suggest a more explicit variable name :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nono its the former, its the event name, i'll change it to something like "name" or "eventName"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually i cant change this as the result json's variable is called "type" and as far as i know Unity's JsonUtility does not have something similar to JsonProperty
|
||
public class SharedAnalyticsEvent | ||
{ | ||
// check if the class for this is in Unity source (if its a bit convoluted just make it) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this comment mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be removed, but i meant to check if theres a class with the same structure as "SharedAnalyticsEvent" already defined within Unity, and if so, use that instead of creating it here
Purpose of this PR
Analytics have been added for our USD package giving us various information about the usage of the package
We thought it would have be needed to have some automated test cases for the analytics
Ticket/Jira #:
[USDU-407]
Testing
Functional Testing status:
Adds functional testcases for the analytics for the following parts:
Could not add planned Recorder analytics automated testing as a lot of recorder aspect is private / internal, and unless I use reflections I cannot instantiate a lot of the classes that I would need to set up the test
LMK if you guys think its needed
Performance Testing status:
Overall Product Risks
Complexity:
Halo Effect:
Additional information
Note to reviewers:
Reminder: