Skip to content

Commit

Permalink
Refactor QueueServerRunConfiguration, remove --queue-server-destinati…
Browse files Browse the repository at this point in the history
…on arg
  • Loading branch information
Vladislav Alekseev committed Aug 7, 2020
1 parent 0037315 commit 9308138
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 96 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 0 additions & 4 deletions Sources/Deployer/DeploymentDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Sources/DistDeployer/QueueServerConfigurationLocation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Foundation
import TypedResourceLocation

public typealias QueueServerConfigurationLocation = TypedResourceLocation<QueueServerConfigurationLocationType>

public final class QueueServerConfigurationLocationType: ResourceLocationType {
public static let name = "queue server configuration"
}

This file was deleted.

10 changes: 5 additions & 5 deletions Sources/DistDeployer/RemoteQueueLaunchdPlist.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions Sources/DistDeployer/RemoteQueueStarter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -20,15 +20,15 @@ public final class RemoteQueueStarter {
deploymentDestination: DeploymentDestination,
emceeVersion: Version,
processControllerProvider: ProcessControllerProvider,
queueServerRunConfigurationLocation: QueueServerRunConfigurationLocation,
queueServerConfigurationLocation: QueueServerConfigurationLocation,
tempFolder: TemporaryFolder,
uniqueIdentifierGenerator: UniqueIdentifierGenerator
) {
self.deploymentId = deploymentId
self.deploymentDestination = deploymentDestination
self.emceeVersion = emceeVersion
self.processControllerProvider = processControllerProvider
self.queueServerRunConfigurationLocation = queueServerRunConfigurationLocation
self.queueServerConfigurationLocation = queueServerConfigurationLocation
self.tempFolder = tempFolder
self.uniqueIdentifierGenerator = uniqueIdentifierGenerator
}
Expand All @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions Sources/EmceeLib/Arguments/ArgumentDescriptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions Sources/EmceeLib/Arguments/ArgumentsReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
36 changes: 18 additions & 18 deletions Sources/EmceeLib/Commands/RunTestsOnRemoteQueueCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
)
Expand All @@ -128,24 +128,24 @@ 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
)
)
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)'")
Expand All @@ -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
)
Expand All @@ -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)'")
Expand Down
Loading

0 comments on commit 9308138

Please sign in to comment.