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

JPERF-451: Give more control over VirtualUserOptions #15

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Dropping a requirement of a major version of a dependency is a new contract.
## [Unreleased]
[Unreleased]: https://github.com/atlassian/aws-infrastructure/compare/release-2.7.3...master

### Added
- Give more control over `VirtualUserOptions`. Resolve [JPERF-451].

### Deprecated
- Deprecate the hardcoded admin credentials in `Infrastructure.applyLoad`.

[JPERF-451]: https://ecosystem.atlassian.net/browse/JPERF-451

## [2.7.3] - 2019-03-28
[2.7.3]: https://github.com/atlassian/aws-infrastructure/compare/release-2.7.2...release-2.7.3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.atlassian.performance.tools.virtualusers.api.config.VirtualUserTarget
import com.google.common.util.concurrent.ThreadFactoryBuilder
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
import java.net.URI
import java.nio.file.Path
import java.util.concurrent.Executors

Expand All @@ -25,22 +26,28 @@ class Infrastructure<out T : VirtualUsers>(
private val logger: Logger = LogManager.getLogger(this::class.java)

fun applyLoad(
behavior: VirtualUserBehavior
options: TargetingVirtualUserOptions
) {
time("applying load") {
virtualUsers.applyLoad(
VirtualUserOptions(
target = VirtualUserTarget(
webApplication = jira.address,
userName = "admin",
password = "admin"
),
behavior = behavior
)
options.target(jira.address)
)
}
}

@Deprecated(
"Use applyLoad(TargetingVirtualUserOptions)",
ReplaceWith(
"applyLoad(LegacyTargetingVirtualUserOptions(behavior))",
"com.atlassian.performance.tools.awsinfrastructure.api.LegacyTargetingVirtualUserOptions"
)
)
fun applyLoad(
behavior: VirtualUserBehavior
) {
applyLoad(LegacyTargetingVirtualUserOptions(behavior))
}

fun downloadResults(
target: Path
): Path {
Expand Down Expand Up @@ -73,6 +80,29 @@ class Infrastructure<out T : VirtualUsers>(
}
}

interface TargetingVirtualUserOptions {

fun target(
jira: URI
): VirtualUserOptions
}

private class LegacyTargetingVirtualUserOptions(
private val behavior: VirtualUserBehavior
) : TargetingVirtualUserOptions {

override fun target(
jira: URI
): VirtualUserOptions = VirtualUserOptions(
target = VirtualUserTarget(
webApplication = jira,
userName = "admin",
password = "admin"
),
behavior = behavior
dagguh marked this conversation as resolved.
Show resolved Hide resolved
)
}

private fun Int.butNotMoreThan(
max: Int
) = Math.min(this, max)