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

[USDU-407] Add automated tests for Analytics #398

Open
wants to merge 22 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4cf765c
Adds Analytics Auto Test
lee-aandrew Jun 28, 2023
bbe7752
Adds Analytics Testcases
lee-aandrew Jul 10, 2023
f5baed0
Fixes formatting issues
lee-aandrew Jul 10, 2023
756fbb4
Removes dependency on Newtonsoft Json + updates requirement for Unity…
lee-aandrew Jul 10, 2023
c327942
Attempt at adding AddPackage at the beginning of the test
lee-aandrew Jul 10, 2023
b92a095
Remove 2 testing lines
lee-aandrew Jul 10, 2023
678ac6f
Removes the AddPackage.cs and dependency on the analytics debugger fr…
lee-aandrew Jul 13, 2023
27e2dbc
Adds Analytics Auto Test
lee-aandrew Jun 28, 2023
021fec9
Adds Analytics Testcases
lee-aandrew Jul 10, 2023
079bc20
Fixes formatting issues
lee-aandrew Jul 10, 2023
d5018a8
Removes dependency on Newtonsoft Json + updates requirement for Unity…
lee-aandrew Jul 10, 2023
f8b2a18
Attempt at adding AddPackage at the beginning of the test
lee-aandrew Jul 10, 2023
00f3942
Remove 2 testing lines
lee-aandrew Jul 10, 2023
aa6bc05
Removes the AddPackage.cs and dependency on the analytics debugger fr…
lee-aandrew Jul 13, 2023
370d07c
Rebase with dev - Test Codes refactor
lee-aandrew Jul 18, 2023
38c98f6
Increase wait frame count for better stability
lee-aandrew Jul 26, 2023
e98e0f9
Merge branch 'AddAnalyticsTest' of https://github.com/Unity-Technolog…
lee-aandrew Jul 26, 2023
d7ad1f1
Apply test code refactoring changes
lee-aandrew Jul 26, 2023
4fa0878
Reverting unnecessary changes
lee-aandrew Jul 26, 2023
2e7398e
Adds analytics test enabling argument
lee-aandrew Jul 27, 2023
2fba851
Fix formatting for yamato script
lee-aandrew Jul 27, 2023
5908426
applying code review fixes
lee-aandrew Aug 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions TestProject/Usd-Development/Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"com.unity.ide.rider": "1.1.4",
"com.unity.recorder": "2.5.5",
"com.unity.test-framework": "1.1.24",
"com.unity.editor-analytics-debugger": "0.1.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
Expand Down Expand Up @@ -39,5 +40,14 @@
},
"testables": [
"com.unity.formats.usd"
],
"scopedRegistries": [
{
"name": "Analytics Debugger",
"url": "https://artifactory.prd.cds.internal.unity3d.com/artifactory/api/npm/upm-candidates",
"scopes": [
"com.unity.editor-analytics-debugger"
]
}
]
}
19 changes: 14 additions & 5 deletions package/com.unity.formats.usd/Common/UsdEditorAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

# if ENABLE_CLOUD_SERVICES_ANALYTICS && UNITY_EDITOR
# define USE_EDITOR_ANALYTICS
# endif

using System;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
Expand All @@ -40,7 +42,11 @@ public static class UsdEditorAnalytics
// Universal USD Analytics
const string k_UsageEventName = "USDPackageUsage";

struct UsageAnalyticsData
public interface IUsdAnalyticsData
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to be unnecessary now since you implemented the UsdAnalyticsEvent class in the tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will revert

{ }

[Serializable]
public struct UsageAnalyticsData : IUsdAnalyticsData
{
public bool InitSucceeded;
public double TimeTakenMs;
Expand All @@ -49,7 +55,8 @@ struct UsageAnalyticsData
// USD Import Analytics
const string k_ImportEventName = "USDFileImport";

struct ImportAnalyticsData
[Serializable]
public struct ImportAnalyticsData : IUsdAnalyticsData
{
public string FileExtension;
public double TimeTakenMs;
Expand Down Expand Up @@ -83,7 +90,8 @@ public struct ImportResult
// USD Reimport Analytics
const string k_ReimportEventName = "USDFileReimport";

struct ReimportAnalyticsData
[Serializable]
public struct ReimportAnalyticsData : IUsdAnalyticsData
{
public string FileExtension;
public double TimeTakenMs;
Expand All @@ -98,7 +106,8 @@ struct ReimportAnalyticsData
// USD Export Analytics
const string k_ExportEventName = "USDFileExport";

struct ExportAnalyticsData
[Serializable]
public struct ExportAnalyticsData : IUsdAnalyticsData
{
public string FileExtension;
public double TimeTakenMs;
Expand All @@ -109,7 +118,7 @@ struct ExportAnalyticsData
// USD Recorder Export Analytics
const string k_RecorderExportEventName = "USDFileRecorderExport";

struct RecorderExportAnalyticsData
public struct RecorderExportAnalyticsData
{
public string FileExtension;
public double TimeTakenMs;
Expand Down
22 changes: 20 additions & 2 deletions package/com.unity.formats.usd/Tests/Common/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public string GetUSDScenePath(string usdFileName = null)
usdFileName = System.Guid.NewGuid().ToString();
}

if (!usdFileName.EndsWith(".usd") && !usdFileName.EndsWith(".usda") && !usdFileName.EndsWith(".usdz"))
if (!usdFileName.EndsWith(".usd") && !usdFileName.EndsWith(".usda") && !usdFileName.EndsWith(".usdz") && !usdFileName.EndsWith(".usdc"))
{
usdFileName += ".usda";
}
Expand All @@ -75,6 +75,8 @@ public string GetPrefabPath(string prefabName = null, bool resource = false)
prefabName += ".prefab";
}

var test = Path.Combine(ArtifactsDirectoryRelativePath, resource ? "Resources" : "", prefabName);
michaeljblain marked this conversation as resolved.
Show resolved Hide resolved
Debug.Log(test);
return Path.Combine(ArtifactsDirectoryRelativePath, resource ? "Resources" : "", prefabName);
}

Expand Down Expand Up @@ -106,6 +108,15 @@ public Scene CreateTestUsdScene(string fileName = "testUsd.usda")
return scene;
}

public Scene CreateEmptyTestUsdScene(string fileName = "testUsd.usda")
{
var dummyUsdPath = CreateTmpUsdFile(fileName);
var scene = ImportHelpers.InitForOpen(dummyUsdPath);
scene.Write("/emptyRoot", new XformSample());
scene.Save();
return scene;
}

[SetUp]
public void InitUSDAndArtifactsDirectory()
{
Expand All @@ -126,7 +137,14 @@ public void CleanupTestArtifacts()
{
if (Directory.Exists(ArtifactsDirectoryFullPath))
{
Directory.Delete(ArtifactsDirectoryFullPath, true);
try
{
Directory.Delete(ArtifactsDirectoryFullPath, true);
}
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.");
Copy link
Collaborator

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?

}
}

DeleteMetaFile(ArtifactsDirectoryFullPath);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invalidFile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading