4
import DeveloperDirModels
8
import MetricsExtensions
12
import SimulatorPoolModels
16
import WorkerCapabilities
17
import WorkerCapabilitiesModels
19
public final class InitTestArgFileCommand: Command {
20
public let name = "initTestArgFile"
21
public let description = "Generates a sample test arg file"
22
public let arguments: Arguments = [
23
ArgumentDescriptions.output.asRequired,
34
public func run(payload: CommandPayload) throws {
35
let logger = try di.get(ContextualLogger.self)
37
let outputPath: AbsolutePath = try payload.expectedSingleTypedValue(argumentName: ArgumentDescriptions.output.name)
39
let testDestination = TestDestination.iOSSimulator(deviceType: "iPhone X", version: "15.1")
41
let testArgFile = TestArgFile(
44
buildArtifacts: AppleBuildArtifacts.iosUiTests(
45
xcTestBundle: XcTestBundle(
46
location: TestBundleLocation(
48
URL(string: "http://storage.example.com/build1234/FunctionalTests.zip#FunctionalTests.xctest")!,
52
testDiscoveryMode: .parseFunctionSymbols
54
appBundle: AppBundleLocation(
56
URL(string: "http://storage.example.com/build1234/MainApp.zip#MainApp.app")!,
58
"X-Header": "You can append arbitrary headers if needed, e.g. for auth",
59
"X-Comment": "Also please read https://github.com/avito-tech/Emcee/wiki/URL-Handling",
63
runner: RunnerAppLocation(
65
URL(string: "http://storage.example.com/build1234/FunctionalTests-Runner.zip#FunctionalTests-Runner.app")!,
69
additionalApplicationBundles: [
70
AdditionalAppBundleLocation(
72
URL(string: "http://storage.example.com/build1234/FunctionalTests.zip#FunctionalTests.xctest")!,
74
"X-Comment": "URL to ZIP file containing addtional .app bundle. Usually this is useful for XC UI tests, which can run additinal apps during test execution",
80
developerDir: DeveloperDir.useXcode(
81
CFBundleShortVersionString: "13.1 - e.g. for Xcode 13.1. Provide here an Xcode version which should be used"
84
"SomeEnvName": "These envs will be available from inside tests, usually via ProcessInfo.environment API",
86
userInsertedLibraries: [],
88
testRetryMode: .retryThroughQueue,
89
logCapturingMode: .onlyCrashLogs,
90
runnerWasteCleanupPolicy: .clean,
92
AppleTestPluginLocation(
94
URL(string: "http://storage.example.com/emceeplugins/MyPlugin.zip#MyPlugin.emceeplugin")!,
96
"X-Comment": "URL to ZIP file containing Emcee plugin bundle with .emceeplugin extension",
97
"X-Docs": "Please refer to https://github.com/avito-tech/Emcee/wiki/Plugins for more information about plugins",
102
scheduleStrategy: TestArgFileDefaultValues.scheduleStrategy,
103
simulatorOperationTimeouts: SimulatorOperationTimeouts(
108
automaticSimulatorShutdown: 600,
109
automaticSimulatorDelete: 200
111
simulatorSettings: TestArgFileDefaultValues.simulatorSettings,
112
testDestination: testDestination,
113
testTimeoutConfiguration: TestArgFileDefaultValues.testTimeoutConfiguration,
114
testAttachmentLifetime: TestArgFileDefaultValues.testAttachmentLifetime,
116
.testName(TestName(className: "ClassName", methodName: "test")),
117
.testName(TestName(className: "ClassName", methodName: "testSpecificTestMethodName__youCanRepeatTestNamesMultipleTimes__toMakeTestRunSeveralTimes")),
118
.testName(TestName(className: "ClassName", methodName: "testSpecificTestMethodName__youCanRepeatTestNamesMultipleTimes__toMakeTestRunSeveralTimes")),
121
workerCapabilityRequirements: [
122
WorkerCapabilityRequirement(
123
capabilityName: XcodeCapabilitiesProvider.workerCapabilityName(
124
shortVersion: "13.1 —— this requirement enforces that tests will only run on workers satisfying this Xcode version requirement."
131
prioritizedJob: PrioritizedJob(
132
analyticsConfiguration: AnalyticsConfiguration(
133
graphiteConfiguration: MetricConfiguration(
134
socketAddress: SocketAddress(
135
host: "graphite.example.com — this is a host name which runs Graphite instance, and its port. Please also refer to https://github.com/avito-tech/Emcee/wiki/Graphite",
138
metricPrefix: "some.prefix.for.emcee"
140
statsdConfiguration: MetricConfiguration(
141
socketAddress: SocketAddress(
142
host: "statsd.example.com — this is a host name which runs Statsd instance, and its port. Please also refer to https://github.com/avito-tech/Emcee/wiki/Graphite",
145
metricPrefix: "some.prefix.for.emcee"
147
kibanaConfiguration: KibanaConfiguration(
149
URL(string: "http://kibana.example.com:12345/")!,
151
indexPattern: "emcee-index-16112021-"
153
persistentMetricsJobId: "UnitTests - set this to allow reporting top-level metrics for jobs with this persistent ID. Useful for statsd metrics which describe top level behaviour of these jobs.",
155
"ciBranchName": "SomeBranchNameWhereTestsAreRunning",
156
"whatisthis": "These values are used for logging purposes. E.g. in Kibana, you can then filter logs by these values.",
159
jobGroupId: JobGroupId(
160
"This is an unique value, e.g. uuid, but it should be common of multiple jobs that are part of the same job group. Please refer to https://github.com/avito-tech/Emcee/wiki/Test-Arg-File#schema."
162
jobGroupPriority: Priority(750),
163
jobId: JobId("This is unique job id. Emcee queue will store test results under this key. Please note, that running additional test run with the same job id will APPEND the test results into previous run. It is better to change this value for each run. UUID can be safely used for this purposes, probably with some human readable additions for ease of understanding, e.g. PR1234_UnitTest_F80A8B88-A209-4694-8847-DC797642655C"),
166
testDestinationConfigurations: [
167
TestDestinationConfiguration(
168
testDestination: testDestination,
169
reportOutput: ReportOutput(
170
junit: "Absolute path to where junit specific for _this test destination_ should be created. --junit will contain the complete junit report.",
171
tracingReport: "Absolute path to where Chrome trace specific for _this test destination_ should be created. --trace will contain the complete trace for the whole test run."
177
let data = try JSONEncoder.pretty().encode(testArgFile)
178
try data.write(to: outputPath.fileUrl)
180
logger.info("Generated test arg file stored at \(outputPath)")