// Copyright Epic Games, Inc. All Rights Reserved.
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using EpicGames.Horde.Commits;
#pragma warning disable CA2227 // Change 'x' to be read-only by removing the property setter
namespace EpicGames.Horde.Jobs.TestData
{
///
/// Test outcome
///
public enum TestOutcome
{
///
/// The test was successful
///
Success,
///
/// The test failed
///
Failure,
///
/// The test was skipped
///
Skipped,
///
/// The test had an unspecified result
///
Unspecified
}
///
/// Test phase outcome
///
public enum TestPhaseOutcome
{
///
/// The phase has failed
///
Failed,
///
/// The phase was successful
///
Success,
///
/// The phase was not run
///
NotRun,
///
/// The phase was interrupted in its execution
///
Interrupted,
///
/// The phase was skipped
///
Skipped,
///
/// The phase outcome is unknown
///
Unknown
}
///
/// Response object describing test data to store
///
public class CreateTestDataRequest
{
///
/// The job which produced the data
///
[Required]
public JobId JobId { get; set; }
///
/// The step that ran
///
[Required]
public JobStepId StepId { get; set; }
///
/// Key used to identify the particular data
///
public string Key { get; set; } = String.Empty;
///
/// The data stored for this test
///
[Required]
public Dictionary Data { get; set; } = new Dictionary();
}
///
/// Response object describing the created document
///
public class CreateTestDataResponse
{
///
/// The id for the new document
///
public string Id { get; set; }
///
/// Constructor
///
/// Id of the new document
public CreateTestDataResponse(string id)
{
Id = id;
}
}
///
/// Response object containing the testdata id and the associated test
///
public class GetJobStepTestDataIDResponse
{
///
/// The unique testdata id
///
public string TestDataId { get; set; } = String.Empty;
///
/// The test key related to the testdata
///
public string TestKey { get; set; } = String.Empty;
///
/// The test name related to the testdata
///
public string TestName { get; set; } = String.Empty;
///
/// The test name reference id related to the testdata
///
public string TestNameRef { get; set; } = String.Empty;
}
///
/// Response object describing test results
///
public class GetTestDataResponse
{
///
/// Unique id of the test data
///
public string Id { get; set; } = String.Empty;
///
/// Stream that generated the test data
///
public string StreamId { get; set; } = String.Empty;
///
/// The template reference id
///
public string TemplateRefId { get; set; } = String.Empty;
///
/// The job which produced the data
///
public string JobId { get; set; } = String.Empty;
///
/// The step that ran
///
public string StepId { get; set; } = String.Empty;
///
/// The changelist number that contained the data
///
[Obsolete("Use CommitId instead")]
public int Change
{
get => _change ?? _commitId?.GetPerforceChangeOrMinusOne() ?? 0;
set => _change = value;
}
int? _change;
///
/// The changelist number that contained the data
///
public CommitIdWithOrder CommitId
{
get => _commitId ?? CommitIdWithOrder.FromPerforceChange(_change) ?? CommitIdWithOrder.Empty;
set => _commitId = value;
}
CommitIdWithOrder? _commitId;
///
/// The preflight commit id if any
///
public CommitId? PreflightCommitId { get; set; }
///
/// Key used to identify the particular data
///
public string Key { get; set; } = String.Empty;
///
/// The data stored for this test
///
public Dictionary Data { get; set; } = new Dictionary();
}
///
/// A test environment running in a stream
///
public class GetTestMetaResponse
{
///
/// Meta unique id for environment
///
public string Id { get; set; } = String.Empty;
///
/// The platforms in the environment
///
public List Platforms { get; set; } = new List();
///
/// The build configurations being tested
///
public List Configurations { get; set; } = new List();
///
/// The build targets being tested
///
public List BuildTargets { get; set; } = new List();
///
/// The test project name
///
public string ProjectName { get; set; } = String.Empty;
///
/// The rendering hardware interface being used with the test
///
public string RHI { get; set; } = String.Empty;
///
/// The variation of the test meta data, for example address sanitizing
///
public string Variation { get; set; } = String.Empty;
}
///
/// A test that runs in a stream
///
public class GetTestResponse
{
///
/// The id of the test
///
public string Id { get; set; } = String.Empty;
///
/// The name of the test
///
public string Name { get; set; } = String.Empty;
///
/// The name of the test
///
public string? DisplayName { get; set; }
///
/// The name of the test suite
///
public string? SuiteName { get; set; }
///
/// The meta data the test runs on
///
public List Metadata { get; set; } = new List();
}
///
/// Get tests request
///
public class GetTestsRequest
{
///
/// Test ids to get
///
public List TestIds { get; set; } = new List();
}
///
/// Get Tests for streams request
///
public class GetStreamTestsRequest
{
///
/// Stream ids to get
///
public List StreamIds { get; set; } = new List();
}
///
/// Get test metadata request
///
public class GetMetadataRequest
{
///
/// Test metadata ids to get
///
public List? MetadataIds { get; set; }
///
/// Matching key/value pair Test metadata to get
///
public Dictionary? Entries { get; set; }
}
///
/// Get test tag request
///
public class GetTestTagRequest
{
///
/// Test tag ids to get
///
public List? TagIds { get; set; }
///
/// Test tag name to get
///
public List? TagNames { get; set; }
}
///
/// Get test phases from test keys and ids request
///
public class GetTestPhasesRequest
{
///
/// Test keys to get
///
public List? TestKeys { get; set; }
///
/// Test ids to get
///
public List? TestIds { get; set; }
}
///
/// Get test sessions from streams, tests and optionally meta ids
///
public class GetTestSessionsRequest
{
///
/// Stream ids to get
///
public List StreamIds { get; set; } = new List();
///
/// Test ids to get
///
public List? TestIds { get; set; }
///
/// Metadata ids to get
///
public List? MetaIds { get; set; }
}
///
/// Get phase sessions from stream and phase ids
///
public class GetPhaseSessionsRequest
{
///
/// Stream ids to get
///
public List StreamIds { get; set; } = new List();
///
/// Phase ids to get
///
public List PhaseIds { get; set; } = new List();
}
///
/// A test suite that runs in a stream, contain subtests
///
public class GetTestSuiteResponse
{
///
/// The id of the suite
///
public string Id { get; set; } = String.Empty;
///
/// The name of the test suite
///
public string Name { get; set; } = String.Empty;
///
/// The meta data the test suite runs on
///
public List Metadata { get; set; } = new List();
}
///
/// Response object describing test results
///
public class GetTestStreamResponse
{
///
/// The stream id
///
public string StreamId { get; set; } = String.Empty;
///
/// Individual tests which run in the stream
///
public List Tests { get; set; } = new List();
///
/// Test suites that run in the stream
///
public List TestSuites { get; set; } = new List();
///
/// Test suites that run in the stream
///
public List TestMetadata { get; set; } = new List();
}
///
/// Suite test data
///
public class GetSuiteTestDataResponse
{
///
/// The test id
///
public string TestId { get; set; } = String.Empty;
///
/// The outcome of the suite test
///
public TestOutcome Outcome { get; set; }
///
/// How long the suite test ran
///
public TimeSpan Duration { get; set; }
///
/// Test UID for looking up in test details
///
public string UID { get; set; } =String.Empty;
///
/// The number of test warnings generated
///
public int? WarningCount { get; set; }
///
/// The number of test errors generated
///
public int? ErrorCount { get; set; }
}
///
/// Test details
///
public class GetTestDataDetailsResponse
{
///
/// The corresponding test ref
///
public string Id { get; set; } = String.Empty;
///
/// The test documents for this ref
///
public List TestDataIds { get; set; } = new List();
///
/// Suite test data
///
public List? SuiteTests { get; set; }
}
///
/// Data ref
///
public class GetTestDataRefResponse
{
///
/// The test ref id
///
public string Id { get; set; } = String.Empty;
///
/// The associated stream
///
public string StreamId { get; set; } = String.Empty;
///
/// The associated job id
///
public string? JobId { get; set; }
///
/// The associated step id
///
public string? StepId { get; set; }
///
/// How long the test ran
///
public TimeSpan Duration { get; set; }
///
/// The build changelist upon which the test ran, may not correspond to the job changelist
///
[Obsolete("Use BuildCommitId instead")]
public int BuildChangeList
{
get => _buildChangeList ?? _buildCommitId?.GetPerforceChangeOrMinusOne() ?? 0;
set => _buildChangeList = value;
}
int? _buildChangeList;
#pragma warning disable CS0618 // Type or member is obsolete
///
/// The build changelist upon which the test ran, may not correspond to the job changelist
///
public CommitId BuildCommitId
{
get => _buildCommitId ?? CommitId.FromPerforceChange(_buildChangeList) ?? CommitId.Empty;
set => _buildCommitId = value;
}
#pragma warning restore CS0618 // Type or member is obsolete
CommitId? _buildCommitId;
///
/// The platform the test ran on
///
public string MetaId { get; set; } = String.Empty;
///
/// The test id in stream
///
public string? TestId { get; set; }
///
/// The outcome of the test
///
public TestOutcome? Outcome { get; set; }
///
/// The if of the stream test suite
///
public string? SuiteId { get; set; }
///
/// Suite tests skipped
///
public int? SuiteSkipCount { get; set; }
///
/// Suite test warnings
///
public int? SuiteWarningCount { get; set; }
///
/// Suite test errors
///
public int? SuiteErrorCount { get; set; }
///
/// Suite test successes
///
public int? SuiteSuccessCount { get; set; }
}
///
/// A test name/key ref
///
public class GetTestNameResponse
{
///
/// The id of the test
///
public string Id { get; set; } = String.Empty;
///
/// The name of the test
///
public string Name { get; set; } = String.Empty;
///
/// The key of the test
///
public string Key { get; set; } = String.Empty;
}
///
/// A set of environment conditions in which a test was run
///
public class GetTestMetadataResponse
{
///
/// Metadata unique id for environment
///
public string Id { get; set; } = String.Empty;
///
/// The set of key/value pairs this environment represent
///
public Dictionary Entries { get; set; } = new Dictionary();
}
///
/// A test tag ref
///
public class GetTestTagResponse
{
///
/// Tag unique id
///
public string Id { get; set; } = String.Empty;
///
/// The name of the tag
///
public string Name { get; set; } = String.Empty;
}
///
/// A test phase from a test
///
public class GetPhaseResponse
{
///
/// The id of the test phase
///
public string Id { get; set; } = String.Empty;
///
/// The name of the test phase
///
public string Name { get; set; } = String.Empty;
///
/// The key of the test phase
///
public string Key { get; set; } = String.Empty;
}
///
/// All test phases from a test
///
public class GetTestPhaseResponse
{
///
/// The id of the test phase
///
public string TestId { get; set; } = String.Empty;
///
/// The name of the test phase
///
public string TestName { get; set; } = String.Empty;
///
/// The key of the test phase
///
public string TestKey { get; set; } = String.Empty;
///
/// The phases associated with the test
///
public List Phases { get; set; } = new List();
}
///
/// Response object describing test results
///
public class GetTestSessionStreamResponse
{
///
/// The stream id
///
public string StreamId { get; set; } = String.Empty;
///
/// Individual tests which run in the stream
///
public List Tests { get; set; } = new List();
///
/// Known test metadata
///
public List TestMetadata { get; set; } = new List();
///
/// Known test tags
///
public List TestTags { get; set; } = new List();
}
///
/// Response object for a test session
///
public class GetTestSessionResponse
{
///
/// The test session id
///
public string Id { get; set; } = String.Empty;
///
/// The stream id associated with the test session
///
public string StreamId { get; set; } = String.Empty;
///
/// Test metadata id associated with the test session
///
public string MetadataId { get; set; } = String.Empty;
///
/// The test data id associated with the test session
///
public string TestDataId { get; set; } = String.Empty;
///
/// The list of tag ids associated with the test session
///
public string[]? TagIds { get; set; }
///
/// The commit id associated with the test session
///
public string CommitId { get; set; } = String.Empty;
///
/// The commit order associated with the test session
///
public int CommitOrder { get; set; } = -1;
///
/// The duration of the test session
///
public double Duration { get; set; }
///
/// The date time at which the test session started
///
public DateTime StartDateTime { get; set; }
///
/// The test name reference associated with the test session
///
public string NameRef { get; set; } = String.Empty;
///
/// The outcome of the test session
///
public TestOutcome Outcome { get; set; }
///
/// The total count of phases
///
public int PhasesTotalCount { get; set; }
///
/// The count of succeeded phases
///
public int PhasesSucceededCount { get; set; }
///
/// The count of undefined phases
///
public int PhasesUndefinedCount { get; set; }
///
/// The count of failed phases
///
public int PhasesFailedCount { get; set; }
///
/// The job id associated with the test session
///
public string JobId { get; set; } = String.Empty;
///
/// The step job id associated with the test session
///
public string StepId { get; set; } = String.Empty;
}
///
/// Response object for a test phase session
///
public class GetTestPhaseSessionResponse
{
///
/// The phase session id
///
public string Id { get; set; } = String.Empty;
///
/// The stream id associated with the phase session
///
public string StreamId { get; set; } = String.Empty;
///
/// Test metadata id associated with the phase session
///
public string MetadataId { get; set; } = String.Empty;
///
/// The test session id associated with the phase session
///
public string SessionId { get; set; } = String.Empty;
///
/// The list of tag ids associated with the phase session
///
public string[]? TagIds { get; set; }
///
/// The commit id associated with the phase session
///
public string CommitId { get; set; } = String.Empty;
///
/// The commit order associated with the phase session
///
public int CommitOrder { get; set; } = -1;
///
/// The duration of the phase session
///
public double Duration { get; set; }
///
/// The date time at which the phase session started
///
public DateTime StartDateTime { get; set; }
///
/// The test phase reference associated with the phase session
///
public string PhaseRef { get; set; } = String.Empty;
///
/// The outcome of the phase session
///
public TestPhaseOutcome Outcome { get; set; }
///
/// The job id associated with the phase session
///
public string JobId { get; set; } = String.Empty;
///
/// The step job id associated with the phase session
///
public string StepId { get; set; } = String.Empty;
///
/// The path to the event stream
///
public string? EventStreamPath { get; set; }
///
/// Whether the test phase encountered at least one warning
///
public bool? HasWarning { get; set; }
///
/// The error fingerprint from the event stream
///
public string? ErrorFingerprint { get; set; }
}
}