From 9308138e692952a2b092ea989ee06e17e2370ab4 Mon Sep 17 00:00:00 2001 From: Vladislav Alekseev Date: Fri, 7 Aug 2020 21:19:45 +0300 Subject: [PATCH] Refactor QueueServerRunConfiguration, remove --queue-server-destination arg --- CHANGELOG.md | 6 +++ Sources/Deployer/DeploymentDestination.swift | 4 -- .../QueueServerConfigurationLocation.swift | 8 ++++ .../QueueServerRunConfigurationLocation.swift | 8 ---- .../RemoteQueueLaunchdPlist.swift | 10 ++--- Sources/DistDeployer/RemoteQueueStarter.swift | 8 ++-- .../Arguments/ArgumentDescriptions.swift | 3 +- .../EmceeLib/Arguments/ArgumentsReader.swift | 6 +-- .../RunTestsOnRemoteQueueCommand.swift | 36 ++++++++-------- .../Commands/StartQueueServerCommand.swift | 43 ++++++++++--------- Sources/EmceeLib/InProcessMain.swift | 1 + .../DestinationConfiguration.swift | 15 ------- ...n.swift => QueueServerConfiguration.swift} | 24 +++++------ .../WorkerSpecificConfiguration.swift | 12 ++++++ .../RemoteQueueLaunchdPlistTests.swift | 4 +- 15 files changed, 92 insertions(+), 96 deletions(-) create mode 100644 Sources/DistDeployer/QueueServerConfigurationLocation.swift delete mode 100644 Sources/DistDeployer/QueueServerRunConfigurationLocation.swift delete mode 100644 Sources/LocalQueueServerRunner/DestinationConfiguration.swift rename Sources/LocalQueueServerRunner/{QueueServerRunConfiguration.swift => QueueServerConfiguration.swift} (60%) create mode 100644 Sources/LocalQueueServerRunner/WorkerSpecificConfiguration.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 374e29e5..b9ece5f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## 2020-08-07 + +- `QueueServerRunConfiguration` and everything related to it has been renamed to `QueueServerConfiguration`, including CLI argument `--queue-server-run-configuration` which was renamed to `--queue-server-configuration`. + +- `--queue-server-destination` argument was removed from `runTestsOnRemoteQueue` command. Queue server deployment destination is now provided via `QueueServerConfiguration.queueServerDeploymentDestination`. + ## 2020-07-31 New `kickstart` command allows to (re-)start a given worker in case if it went south. Syntax: diff --git a/Sources/Deployer/DeploymentDestination.swift b/Sources/Deployer/DeploymentDestination.swift index e84cc51f..70119f1f 100644 --- a/Sources/Deployer/DeploymentDestination.swift +++ b/Sources/Deployer/DeploymentDestination.swift @@ -2,10 +2,6 @@ import Foundation import QueueModels public struct DeploymentDestination: Codable, CustomStringConvertible, Hashable { - /** - * Identifier can be used to apply additional configuration for this destination, see DestinationConfiguration - * If identifier is not specified explicitly, the host name will be used as an identifier. - */ public let workerId: WorkerId public let host: String public let port: Int32 diff --git a/Sources/DistDeployer/QueueServerConfigurationLocation.swift b/Sources/DistDeployer/QueueServerConfigurationLocation.swift new file mode 100644 index 00000000..3e487780 --- /dev/null +++ b/Sources/DistDeployer/QueueServerConfigurationLocation.swift @@ -0,0 +1,8 @@ +import Foundation +import TypedResourceLocation + +public typealias QueueServerConfigurationLocation = TypedResourceLocation + +public final class QueueServerConfigurationLocationType: ResourceLocationType { + public static let name = "queue server configuration" +} diff --git a/Sources/DistDeployer/QueueServerRunConfigurationLocation.swift b/Sources/DistDeployer/QueueServerRunConfigurationLocation.swift deleted file mode 100644 index 9351862f..00000000 --- a/Sources/DistDeployer/QueueServerRunConfigurationLocation.swift +++ /dev/null @@ -1,8 +0,0 @@ -import Foundation -import TypedResourceLocation - -public typealias QueueServerRunConfigurationLocation = TypedResourceLocation - -public final class QueueServerRunConfigurationLocationType: ResourceLocationType { - public static let name = "queue server run configuration" -} diff --git a/Sources/DistDeployer/RemoteQueueLaunchdPlist.swift b/Sources/DistDeployer/RemoteQueueLaunchdPlist.swift index 71e9e655..abe0f2b3 100644 --- a/Sources/DistDeployer/RemoteQueueLaunchdPlist.swift +++ b/Sources/DistDeployer/RemoteQueueLaunchdPlist.swift @@ -14,21 +14,21 @@ public final class RemoteQueueLaunchdPlist { private let emceeVersion: Version /// Queue server executable private let queueServerBinaryDeployableItem: DeployableItem - /// A JSON file location that contains QueueServerRunConfiguration for queue server - private let queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation + /// A JSON file location that contains QueueServerConfiguration for queue server + private let queueServerConfigurationLocation: QueueServerConfigurationLocation public init( deploymentId: String, deploymentDestination: DeploymentDestination, emceeDeployableItem: DeployableItem, emceeVersion: Version, - queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation + queueServerConfigurationLocation: QueueServerConfigurationLocation ) { self.deploymentId = deploymentId self.deploymentDestination = deploymentDestination self.emceeVersion = emceeVersion self.queueServerBinaryDeployableItem = emceeDeployableItem - self.queueServerRunConfigurationLocation = queueServerRunConfigurationLocation + self.queueServerConfigurationLocation = queueServerConfigurationLocation } public func plistData() throws -> Data { @@ -54,7 +54,7 @@ public final class RemoteQueueLaunchdPlist { programArguments: [ remoteQueueServerBinaryPath.pathString, "startLocalQueueServer", "--emcee-version", emceeVersion.value, - "--queue-server-run-configuration-location", queueServerRunConfigurationLocation.resourceLocation.stringValue + "--queue-server-configuration-location", queueServerConfigurationLocation.resourceLocation.stringValue ], environmentVariables: [:], workingDirectory: containerPath.pathString, diff --git a/Sources/DistDeployer/RemoteQueueStarter.swift b/Sources/DistDeployer/RemoteQueueStarter.swift index 85c4b7bd..32b0f5ce 100644 --- a/Sources/DistDeployer/RemoteQueueStarter.swift +++ b/Sources/DistDeployer/RemoteQueueStarter.swift @@ -11,7 +11,7 @@ public final class RemoteQueueStarter { private let deploymentDestination: DeploymentDestination private let emceeVersion: Version private let processControllerProvider: ProcessControllerProvider - private let queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation + private let queueServerConfigurationLocation: QueueServerConfigurationLocation private let tempFolder: TemporaryFolder private let uniqueIdentifierGenerator: UniqueIdentifierGenerator @@ -20,7 +20,7 @@ public final class RemoteQueueStarter { deploymentDestination: DeploymentDestination, emceeVersion: Version, processControllerProvider: ProcessControllerProvider, - queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation, + queueServerConfigurationLocation: QueueServerConfigurationLocation, tempFolder: TemporaryFolder, uniqueIdentifierGenerator: UniqueIdentifierGenerator ) { @@ -28,7 +28,7 @@ public final class RemoteQueueStarter { self.deploymentDestination = deploymentDestination self.emceeVersion = emceeVersion self.processControllerProvider = processControllerProvider - self.queueServerRunConfigurationLocation = queueServerRunConfigurationLocation + self.queueServerConfigurationLocation = queueServerConfigurationLocation self.tempFolder = tempFolder self.uniqueIdentifierGenerator = uniqueIdentifierGenerator } @@ -54,7 +54,7 @@ public final class RemoteQueueStarter { deploymentDestination: deploymentDestination, emceeDeployableItem: emceeBinaryDeployableItem, emceeVersion: emceeVersion, - queueServerRunConfigurationLocation: queueServerRunConfigurationLocation + queueServerConfigurationLocation: queueServerConfigurationLocation ) let launchdPlistDeployableItem = DeployableItem( name: "queue_server_launchd_plist", diff --git a/Sources/EmceeLib/Arguments/ArgumentDescriptions.swift b/Sources/EmceeLib/Arguments/ArgumentDescriptions.swift index d66df9ac..70a8d653 100644 --- a/Sources/EmceeLib/Arguments/ArgumentDescriptions.swift +++ b/Sources/EmceeLib/Arguments/ArgumentDescriptions.swift @@ -11,8 +11,7 @@ final class ArgumentDescriptions { static let plugin = doubleDashedDescription(dashlessName: "plugin", overview: "URL to ZIP file with .emceeplugin bundle. Plugin bundle should contain an executable: MyPlugin.emceeplugin/Plugin", multiple: true) static let priority = doubleDashedDescription(dashlessName: "priority", overview: "Job priority. Possible values are in range: [0...999]") static let queueServer = doubleDashedDescription(dashlessName: "queue-server", overview: "An address to a server which runs job queues, e.g. 127.0.0.1:1234") - static let queueServerDestination = doubleDashedDescription(dashlessName: "queue-server-destination", overview: "A JSON file with info about deployment destination which will be used to start remote queue server") - static let queueServerRunConfigurationLocation = doubleDashedDescription(dashlessName: "queue-server-run-configuration-location", overview: "JSON file location which describes QueueServerRunConfiguration. Either /path/to/file.json, or http://example.com/file.zip#path/to/config.json") + static let queueServerConfigurationLocation = doubleDashedDescription(dashlessName: "queue-server-configuration-location", overview: "JSON file location which describes QueueServerConfiguration, e.g. http://example.com/file.zip#path/to/config.json") static let remoteCacheConfig = doubleDashedDescription(dashlessName: "remote-cache-config", overview: "JSON file with remote server settings") static let setFeatureStatus = doubleDashedDescription(dashlessName: "set-feature-status", overview: "Enabled/Disabled") static let tempFolder = doubleDashedDescription(dashlessName: "temp-folder", overview: "Where to store temporary stuff, including simulator data") diff --git a/Sources/EmceeLib/Arguments/ArgumentsReader.swift b/Sources/EmceeLib/Arguments/ArgumentsReader.swift index 3a9faac1..72b75726 100644 --- a/Sources/EmceeLib/Arguments/ArgumentsReader.swift +++ b/Sources/EmceeLib/Arguments/ArgumentsReader.swift @@ -40,10 +40,10 @@ final class ArgumentsReader { return try decodeModelsFromFile(file, jsonDecoder: decoderWithSnakeCaseSupport) } - public static func queueServerRunConfiguration( - location: QueueServerRunConfigurationLocation, + public static func queueServerConfiguration( + location: QueueServerConfigurationLocation, resourceLocationResolver: ResourceLocationResolver - ) throws -> QueueServerRunConfiguration { + ) throws -> QueueServerConfiguration { let resolvingResult = try resourceLocationResolver.resolvePath(resourceLocation: location.resourceLocation) return try decodeModelsFromFile( try resolvingResult.directlyAccessibleResourcePath().pathString, diff --git a/Sources/EmceeLib/Commands/RunTestsOnRemoteQueueCommand.swift b/Sources/EmceeLib/Commands/RunTestsOnRemoteQueueCommand.swift index 13b6c845..e8edf766 100644 --- a/Sources/EmceeLib/Commands/RunTestsOnRemoteQueueCommand.swift +++ b/Sources/EmceeLib/Commands/RunTestsOnRemoteQueueCommand.swift @@ -38,8 +38,7 @@ public final class RunTestsOnRemoteQueueCommand: Command { ArgumentDescriptions.jobGroupPriority.asOptional, ArgumentDescriptions.jobId.asRequired, ArgumentDescriptions.junit.asOptional, - ArgumentDescriptions.queueServerDestination.asRequired, - ArgumentDescriptions.queueServerRunConfigurationLocation.asRequired, + ArgumentDescriptions.queueServerConfigurationLocation.asRequired, ArgumentDescriptions.remoteCacheConfig.asOptional, ArgumentDescriptions.tempFolder.asRequired, ArgumentDescriptions.testArgFile.asRequired, @@ -83,12 +82,13 @@ public final class RunTestsOnRemoteQueueCommand: Command { junit: try payload.optionalSingleTypedValue(argumentName: ArgumentDescriptions.junit.name), tracingReport: try payload.optionalSingleTypedValue(argumentName: ArgumentDescriptions.trace.name) ) - - let queueServerDestination = try ArgumentsReader.deploymentDestinations( - try payload.expectedSingleTypedValue(argumentName: ArgumentDescriptions.queueServerDestination.name) - ).elementAtIndex(0, "first and single queue server destination") - - let queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation = try payload.expectedSingleTypedValue(argumentName: ArgumentDescriptions.queueServerRunConfigurationLocation.name) + + let queueServerConfigurationLocation: QueueServerConfigurationLocation = try payload.expectedSingleTypedValue(argumentName: ArgumentDescriptions.queueServerConfigurationLocation.name) + let queueServerConfiguration = try ArgumentsReader.queueServerConfiguration( + location: queueServerConfigurationLocation, + resourceLocationResolver: resourceLocationResolver + ) + let jobId: JobId = try payload.expectedSingleTypedValue(argumentName: ArgumentDescriptions.jobId.name) let jobGroupId: JobGroupId = try payload.optionalSingleTypedValue(argumentName: ArgumentDescriptions.jobGroupId.name) ?? JobGroupId(value: jobId.value) let emceeVersion: Version = try payload.optionalSingleTypedValue(argumentName: ArgumentDescriptions.emceeVersion.name) ?? EmceeVersion.version @@ -103,8 +103,8 @@ public final class RunTestsOnRemoteQueueCommand: Command { let runningQueueServerAddress = try detectRemotelyRunningQueueServerPortsOrStartRemoteQueueIfNeeded( emceeVersion: emceeVersion, - queueServerDestination: queueServerDestination, - queueServerRunConfigurationLocation: queueServerRunConfigurationLocation, + queueServerDeploymentDestination: queueServerConfiguration.queueServerDeploymentDestination, + queueServerConfigurationLocation: queueServerConfigurationLocation, jobId: jobId, tempFolder: tempFolder ) @@ -128,16 +128,16 @@ public final class RunTestsOnRemoteQueueCommand: Command { private func detectRemotelyRunningQueueServerPortsOrStartRemoteQueueIfNeeded( emceeVersion: Version, - queueServerDestination: DeploymentDestination, - queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation, + queueServerDeploymentDestination: DeploymentDestination, + queueServerConfigurationLocation: QueueServerConfigurationLocation, jobId: JobId, tempFolder: TemporaryFolder ) throws -> SocketAddress { - Logger.info("Searching for queue server on '\(queueServerDestination.host)' with queue version \(emceeVersion)") + Logger.info("Searching for queue server on '\(queueServerDeploymentDestination.host)' with queue version \(emceeVersion)") let remoteQueueDetector = DefaultRemoteQueueDetector( emceeVersion: emceeVersion, remotePortDeterminer: RemoteQueuePortScanner( - host: queueServerDestination.host, + host: queueServerDeploymentDestination.host, portRange: EmceePorts.defaultQueuePortRange, requestSenderProvider: requestSenderProvider ) @@ -145,7 +145,7 @@ public final class RunTestsOnRemoteQueueCommand: Command { var suitablePorts = try remoteQueueDetector.findSuitableRemoteRunningQueuePorts(timeout: 10) if !suitablePorts.isEmpty { let socketAddress = SocketAddress( - host: queueServerDestination.host, + host: queueServerDeploymentDestination.host, port: try selectPort(ports: suitablePorts) ) Logger.info("Found queue server at '\(socketAddress)'") @@ -155,10 +155,10 @@ public final class RunTestsOnRemoteQueueCommand: Command { Logger.info("No running queue server has been found. Will deploy and start remote queue.") let remoteQueueStarter = RemoteQueueStarter( deploymentId: jobId.value, - deploymentDestination: queueServerDestination, + deploymentDestination: queueServerDeploymentDestination, emceeVersion: emceeVersion, processControllerProvider: processControllerProvider, - queueServerRunConfigurationLocation: queueServerRunConfigurationLocation, + queueServerConfigurationLocation: queueServerConfigurationLocation, tempFolder: tempFolder, uniqueIdentifierGenerator: uniqueIdentifierGenerator ) @@ -177,7 +177,7 @@ public final class RunTestsOnRemoteQueueCommand: Command { } let queueServerAddress = SocketAddress( - host: queueServerDestination.host, + host: queueServerDeploymentDestination.host, port: try selectPort(ports: suitablePorts) ) Logger.info("Found queue server at '\(queueServerAddress)'") diff --git a/Sources/EmceeLib/Commands/StartQueueServerCommand.swift b/Sources/EmceeLib/Commands/StartQueueServerCommand.swift index e6889952..e752006e 100644 --- a/Sources/EmceeLib/Commands/StartQueueServerCommand.swift +++ b/Sources/EmceeLib/Commands/StartQueueServerCommand.swift @@ -27,23 +27,26 @@ public final class StartQueueServerCommand: Command { public let description = "Starts queue server on local machine. This mode waits for jobs to be scheduled via REST API." public let arguments: Arguments = [ ArgumentDescriptions.emceeVersion.asOptional, - ArgumentDescriptions.queueServerRunConfigurationLocation.asRequired + ArgumentDescriptions.queueServerConfigurationLocation.asRequired ] + private let dateProvider: DateProvider private let deployQueue = DispatchQueue(label: "StartQueueServerCommand.deployQueue", attributes: .concurrent, target: .global(qos: .default)) - private let requestSenderProvider: RequestSenderProvider private let payloadSignature: PayloadSignature private let processControllerProvider: ProcessControllerProvider + private let requestSenderProvider: RequestSenderProvider private let resourceLocationResolver: ResourceLocationResolver private let uniqueIdentifierGenerator: UniqueIdentifierGenerator public init( + dateProvider: DateProvider, requestSenderProvider: RequestSenderProvider, payloadSignature: PayloadSignature, processControllerProvider: ProcessControllerProvider, resourceLocationResolver: ResourceLocationResolver, uniqueIdentifierGenerator: UniqueIdentifierGenerator ) { + self.dateProvider = dateProvider self.requestSenderProvider = requestSenderProvider self.payloadSignature = payloadSignature self.processControllerProvider = processControllerProvider @@ -53,29 +56,29 @@ public final class StartQueueServerCommand: Command { public func run(payload: CommandPayload) throws { let emceeVersion: Version = try payload.optionalSingleTypedValue(argumentName: ArgumentDescriptions.emceeVersion.name) ?? EmceeVersion.version - let queueServerRunConfiguration = try ArgumentsReader.queueServerRunConfiguration( - location: try payload.expectedSingleTypedValue(argumentName: ArgumentDescriptions.queueServerRunConfigurationLocation.name), + let queueServerConfiguration = try ArgumentsReader.queueServerConfiguration( + location: try payload.expectedSingleTypedValue(argumentName: ArgumentDescriptions.queueServerConfigurationLocation.name), resourceLocationResolver: resourceLocationResolver ) - try AnalyticsSetup.setupAnalytics(analyticsConfiguration: queueServerRunConfiguration.analyticsConfiguration, emceeVersion: emceeVersion) + try AnalyticsSetup.setupAnalytics(analyticsConfiguration: queueServerConfiguration.analyticsConfiguration, emceeVersion: emceeVersion) try startQueueServer( emceeVersion: emceeVersion, - queueServerRunConfiguration: queueServerRunConfiguration, - workerDestinations: queueServerRunConfiguration.workerDeploymentDestinations + queueServerConfiguration: queueServerConfiguration, + workerDestinations: queueServerConfiguration.workerDeploymentDestinations ) } private func startQueueServer( emceeVersion: Version, - queueServerRunConfiguration: QueueServerRunConfiguration, + queueServerConfiguration: QueueServerConfiguration, workerDestinations: [DeploymentDestination] ) throws { Logger.info("Generated payload signature: \(payloadSignature)") let automaticTerminationController = AutomaticTerminationControllerFactory( - automaticTerminationPolicy: queueServerRunConfiguration.queueServerTerminationPolicy + automaticTerminationPolicy: queueServerConfiguration.queueServerTerminationPolicy ).createAutomaticTerminationController() let socketHost = LocalHostDeterminer.currentHostAddress @@ -101,8 +104,6 @@ public final class StartQueueServerCommand: Command { communicationService: queueCommunicationService ) - let dateProvider = SystemDateProvider() - let workersToUtilizeService = DefaultWorkersToUtilizeService( cache: DefaultWorkersMappingCache(cacheIvalidationTime: 300, dateProvider: dateProvider), calculator: DefaultWorkersToUtilizeCalculator(), @@ -122,9 +123,9 @@ public final class StartQueueServerCommand: Command { let queueServer = QueueServerImpl( automaticTerminationController: automaticTerminationController, bucketSplitInfo: BucketSplitInfo( - numberOfWorkers: UInt(queueServerRunConfiguration.deploymentDestinationConfigurations.count) + numberOfWorkers: UInt(queueServerConfiguration.workerSpecificConfigurations.count) ), - checkAgainTimeInterval: queueServerRunConfiguration.checkAgainTimeInterval, + checkAgainTimeInterval: queueServerConfiguration.checkAgainTimeInterval, dateProvider: dateProvider, deploymentDestinations: workerDestinations, emceeVersion: emceeVersion, @@ -140,7 +141,7 @@ public final class StartQueueServerCommand: Command { requestSenderProvider: requestSenderProvider, uniqueIdentifierGenerator: uniqueIdentifierGenerator, workerConfigurations: createWorkerConfigurations( - queueServerRunConfiguration: queueServerRunConfiguration + queueServerConfiguration: queueServerConfiguration ), workerUtilizationStatusPoller: workerUtilizationStatusPoller, workersToUtilizeService: workersToUtilizeService @@ -150,7 +151,7 @@ public final class StartQueueServerCommand: Command { let pollPeriod: TimeInterval = 5.0 let queueServerTerminationWaiter = QueueServerTerminationWaiterImpl( pollInterval: pollPeriod, - queueServerTerminationPolicy: queueServerRunConfiguration.queueServerTerminationPolicy + queueServerTerminationPolicy: queueServerConfiguration.queueServerTerminationPolicy ) let localQueueServerRunner = LocalQueueServerRunner( @@ -159,7 +160,7 @@ public final class StartQueueServerCommand: Command { newWorkerRegistrationTimeAllowance: 360.0, pollPeriod: pollPeriod, queueServer: queueServer, - queueServerTerminationPolicy: queueServerRunConfiguration.queueServerTerminationPolicy, + queueServerTerminationPolicy: queueServerConfiguration.queueServerTerminationPolicy, queueServerTerminationWaiter: queueServerTerminationWaiter, remotePortDeterminer: remotePortDeterminer, remoteWorkerStarterProvider: remoteWorkerStarterProvider, @@ -170,14 +171,14 @@ public final class StartQueueServerCommand: Command { } private func createWorkerConfigurations( - queueServerRunConfiguration: QueueServerRunConfiguration + queueServerConfiguration: QueueServerConfiguration ) -> WorkerConfigurations { let configurations = WorkerConfigurations() - for deploymentDestinationConfiguration in queueServerRunConfiguration.deploymentDestinationConfigurations { + for (workerId, workerSpecificConfiguration) in queueServerConfiguration.workerSpecificConfigurations { configurations.add( - workerId: deploymentDestinationConfiguration.destinationIdentifier, - configuration: queueServerRunConfiguration.workerConfiguration( - deploymentDestinationConfiguration: deploymentDestinationConfiguration, + workerId: workerId, + configuration: queueServerConfiguration.workerConfiguration( + workerSpecificConfiguration: workerSpecificConfiguration, payloadSignature: payloadSignature ) ) diff --git a/Sources/EmceeLib/InProcessMain.swift b/Sources/EmceeLib/InProcessMain.swift index 1d132c2e..d92f0bbd 100644 --- a/Sources/EmceeLib/InProcessMain.swift +++ b/Sources/EmceeLib/InProcessMain.swift @@ -104,6 +104,7 @@ public final class InProcessMain { runtimeDumpRemoteCacheProvider: runtimeDumpRemoteCacheProvider ), StartQueueServerCommand( + dateProvider: dateProvider, requestSenderProvider: requestSenderProvider, payloadSignature: PayloadSignature(value: UUID().uuidString), processControllerProvider: processControllerProvider, diff --git a/Sources/LocalQueueServerRunner/DestinationConfiguration.swift b/Sources/LocalQueueServerRunner/DestinationConfiguration.swift deleted file mode 100644 index 464d18ae..00000000 --- a/Sources/LocalQueueServerRunner/DestinationConfiguration.swift +++ /dev/null @@ -1,15 +0,0 @@ -import Foundation -import QueueModels - -public struct DestinationConfiguration: Decodable { - /// This is an identifier of the DeploymentDestination - public let destinationIdentifier: WorkerId - - /// The value for the number of simulators that can be used on this destination. - public let numberOfSimulators: UInt - - public init(destinationIdentifier: WorkerId, numberOfSimulators: UInt) { - self.destinationIdentifier = destinationIdentifier - self.numberOfSimulators = numberOfSimulators - } -} diff --git a/Sources/LocalQueueServerRunner/QueueServerRunConfiguration.swift b/Sources/LocalQueueServerRunner/QueueServerConfiguration.swift similarity index 60% rename from Sources/LocalQueueServerRunner/QueueServerRunConfiguration.swift rename to Sources/LocalQueueServerRunner/QueueServerConfiguration.swift index 4c878295..039d7349 100644 --- a/Sources/LocalQueueServerRunner/QueueServerRunConfiguration.swift +++ b/Sources/LocalQueueServerRunner/QueueServerConfiguration.swift @@ -5,41 +5,37 @@ import Foundation import LoggingSetup import QueueModels -public struct QueueServerRunConfiguration: Decodable { +public struct QueueServerConfiguration: Decodable { public let analyticsConfiguration: AnalyticsConfiguration - - /// Delay after workers should ask for a next bucket when all jobs are depleted public let checkAgainTimeInterval: TimeInterval - - /// A list of additional per-destination configurations. - public let deploymentDestinationConfigurations: [DestinationConfiguration] - - /// Defines when queue server will terminate itself. + public let queueServerDeploymentDestination: DeploymentDestination public let queueServerTerminationPolicy: AutomaticTerminationPolicy - public let workerDeploymentDestinations: [DeploymentDestination] + public let workerSpecificConfigurations: [WorkerId: WorkerSpecificConfiguration] public init( analyticsConfiguration: AnalyticsConfiguration, checkAgainTimeInterval: TimeInterval, - deploymentDestinationConfigurations: [DestinationConfiguration], + queueServerDeploymentDestination: DeploymentDestination, queueServerTerminationPolicy: AutomaticTerminationPolicy, - workerDeploymentDestinations: [DeploymentDestination] + workerDeploymentDestinations: [DeploymentDestination], + workerSpecificConfigurations: [WorkerId: WorkerSpecificConfiguration] ) { self.analyticsConfiguration = analyticsConfiguration self.checkAgainTimeInterval = checkAgainTimeInterval - self.deploymentDestinationConfigurations = deploymentDestinationConfigurations + self.queueServerDeploymentDestination = queueServerDeploymentDestination self.queueServerTerminationPolicy = queueServerTerminationPolicy self.workerDeploymentDestinations = workerDeploymentDestinations + self.workerSpecificConfigurations = workerSpecificConfigurations } public func workerConfiguration( - deploymentDestinationConfiguration: DestinationConfiguration, + workerSpecificConfiguration: WorkerSpecificConfiguration, payloadSignature: PayloadSignature ) -> WorkerConfiguration { return WorkerConfiguration( analyticsConfiguration: analyticsConfiguration, - numberOfSimulators: deploymentDestinationConfiguration.numberOfSimulators, + numberOfSimulators: workerSpecificConfiguration.numberOfSimulators, payloadSignature: payloadSignature ) } diff --git a/Sources/LocalQueueServerRunner/WorkerSpecificConfiguration.swift b/Sources/LocalQueueServerRunner/WorkerSpecificConfiguration.swift new file mode 100644 index 00000000..33690565 --- /dev/null +++ b/Sources/LocalQueueServerRunner/WorkerSpecificConfiguration.swift @@ -0,0 +1,12 @@ +import Foundation +import QueueModels + +public struct WorkerSpecificConfiguration: Decodable { + public let numberOfSimulators: UInt + + public init( + numberOfSimulators: UInt + ) { + self.numberOfSimulators = numberOfSimulators + } +} diff --git a/Tests/DistDeployerTests/RemoteQueueLaunchdPlistTests.swift b/Tests/DistDeployerTests/RemoteQueueLaunchdPlistTests.swift index 82863c11..008e3751 100644 --- a/Tests/DistDeployerTests/RemoteQueueLaunchdPlistTests.swift +++ b/Tests/DistDeployerTests/RemoteQueueLaunchdPlistTests.swift @@ -22,7 +22,7 @@ final class RemoteQueueLaunchdPlistTests: XCTestCase { ] ), emceeVersion: emceeVersion, - queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation(.remoteUrl(remoteConfigUrl)) + queueServerConfigurationLocation: QueueServerConfigurationLocation(.remoteUrl(remoteConfigUrl)) ) func test() throws { @@ -38,7 +38,7 @@ final class RemoteQueueLaunchdPlistTests: XCTestCase { "/Users/username/path/deploymentId/emcee/remote_filename", "startLocalQueueServer", "--emcee-version", emceeVersion.value, - "--queue-server-run-configuration-location", remoteConfigUrl.absoluteString + "--queue-server-configuration-location", remoteConfigUrl.absoluteString ] ) XCTAssertEqual(