-
Notifications
You must be signed in to change notification settings - Fork 845
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
Fixes #2294 - Make boolean command line flags use Scallop's 'toggle' #2296
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package mesosphere.marathon | ||
|
||
import mesosphere.chaos.AppConfiguration | ||
import mesosphere.chaos.http.HttpConf | ||
import mesosphere.marathon.core.plugin.PluginConfiguration | ||
import mesosphere.marathon.event.EventConfiguration | ||
import mesosphere.marathon.event.http.HttpEventConfiguration | ||
import org.rogach.scallop.ScallopConf | ||
|
||
class AllConf(args: Seq[String] = Nil) extends ScallopConf(args) | ||
with HttpConf | ||
with MarathonConf | ||
with AppConfiguration | ||
with EventConfiguration | ||
with HttpEventConfiguration | ||
with DebugConf | ||
with PluginConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,26 +11,31 @@ import org.rogach.scallop.ScallopConf | |
|
||
/** | ||
* Options related to debugging marathon. | ||
* All options should be optional and turned off by default. | ||
*/ | ||
trait DebugConf extends ScallopConf { | ||
|
||
lazy val debugTracing = opt[Boolean]("enable_tracing", | ||
descr = "Enable trace logging of service method calls", | ||
lazy val debugTracing = toggle("tracing", | ||
descrYes = "Enable trace logging of service method calls", | ||
descrNo = "(Default) Disable trace logging of service method calls", | ||
default = Some(false), | ||
noshort = true) | ||
noshort = true, | ||
prefix = "disable_") | ||
|
||
@deprecated("Metrics are enabled by default. See disableMetrics.", "Since version 0.10.0") | ||
lazy val enableMetrics = opt[Boolean]("enable_metrics", | ||
descr = "Enable metric measurement of service method calls", | ||
hidden = true, | ||
lazy val deprecatedDebugTracing = opt[Boolean]("enable_tracing", hidden = true) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. keep this as a hidden option to ignore the comment and allow Marathon to startup |
||
|
||
mutuallyExclusive(debugTracing, deprecatedDebugTracing) | ||
lazy val enableDebugTracing = debugTracing() || deprecatedDebugTracing() | ||
|
||
lazy val metrics = toggle("metrics", | ||
descrYes = "(Default) Enable metric measurement of service method calls", | ||
descrNo = "Disable metric measurement of service method calls", | ||
default = Some(true), | ||
noshort = true) | ||
noshort = true, | ||
prefix = "disable_") | ||
|
||
lazy val disableMetrics = opt[Boolean]("disable_metrics", | ||
descr = "Disable metric measurement of service method calls", | ||
default = Some(false), | ||
noshort = true) | ||
lazy val deprecatedEnableMetrics = opt[Boolean]("enable_metrics", default = Some(false), hidden = true) | ||
|
||
mutuallyExclusive(metrics, deprecatedEnableMetrics) | ||
|
||
lazy val logLevel = opt[String]("logging_level", | ||
descr = "Set logging level to one of: off, fatal, error, warn, info, debug, trace, all", | ||
|
@@ -81,8 +86,8 @@ class DebugModule(conf: DebugConf) extends AbstractModule { | |
//add behaviors | ||
val metricsProvider = getProvider(classOf[Metrics]) | ||
|
||
val tracingBehavior = conf.debugTracing.get.filter(identity).map(_ => new TracingBehavior(metricsProvider)) | ||
val metricsBehavior = conf.disableMetrics.get.filterNot(identity).map(_ => new MetricsBehavior(metricsProvider)) | ||
val tracingBehavior = if (conf.enableDebugTracing) Some(new TracingBehavior(metricsProvider)) else None | ||
val metricsBehavior = conf.metrics.get.filter(identity).map(_ => new MetricsBehavior(metricsProvider)) | ||
|
||
val behaviors = (tracingBehavior :: metricsBehavior :: Nil).flatten | ||
if (behaviors.nonEmpty) bindInterceptor(MarathonMatcher, Matchers.any(), behaviors: _*) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package mesosphere.marathon | ||
|
||
class DebugConfTest extends MarathonSpec { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that you separated this test suite from the rest :) |
||
test("tracing is disabled by default") { | ||
val conf = defaultConfig() | ||
assert(!conf.debugTracing()) | ||
} | ||
|
||
test("tracing can be enabled") { | ||
val conf = makeConfig( | ||
"--master", "127.0.0.1:5050", | ||
"--tracing" | ||
) | ||
assert(conf.enableDebugTracing) | ||
} | ||
|
||
test("tracing can be enabled using the deprecated ---enable_tracing") { | ||
val conf = makeConfig( | ||
"--master", "127.0.0.1:5050", | ||
"--enable_tracing" | ||
) | ||
assert(conf.enableDebugTracing) | ||
} | ||
|
||
test("tracing can be disabled") { | ||
val conf = makeConfig("" + | ||
"--master", "127.0.0.1:5050", | ||
"--disable_tracing" | ||
) | ||
assert(!conf.enableDebugTracing) | ||
} | ||
|
||
test("metrics are enabled by default") { | ||
val conf = defaultConfig() | ||
assert(conf.metrics()) | ||
} | ||
|
||
test("metrics can be enabled") { | ||
val conf = makeConfig( | ||
"--master", "127.0.0.1:5050", | ||
"--metrics" | ||
) | ||
assert(conf.metrics()) | ||
} | ||
|
||
test("the deprecated --enable_metrics is accepted") { | ||
val conf = makeConfig( | ||
"--master", "127.0.0.1:5050", | ||
"--enable_metrics" | ||
) | ||
assert(conf.metrics()) | ||
} | ||
|
||
test("metrics can be disabled") { | ||
val conf = makeConfig( | ||
"--master", "127.0.0.1:5050", | ||
"--disable_metrics" | ||
) | ||
assert(!conf.metrics()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/scala/mesosphere/marathon/core/flow/ReviveOffersConfigTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package mesosphere.marathon.core.flow | ||
|
||
import mesosphere.marathon.MarathonSpec | ||
|
||
class ReviveOffersConfigTest extends MarathonSpec { | ||
test("reviveOffersForNewApps is enabled by default") { | ||
val conf = defaultConfig() | ||
assert(conf.reviveOffersForNewApps()) | ||
} | ||
|
||
test("disable reviveOffersForNewApps") { | ||
val conf = makeConfig( | ||
"--master", "127.0.0.1:5050", | ||
"--disable_revive_offers_for_new_apps" | ||
) | ||
assert(!conf.reviveOffersForNewApps()) | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep this as a hidden option to ignore the comment and allow Marathon to startup