Skip to content
Snippets Groups Projects
Commit 9cea0c28 authored by Andrew xia's avatar Andrew xia Committed by jerryshao
Browse files

Refactor metricsSystem unit test, add resource files.

parent 7d2eada4
No related branches found
No related tags found
No related merge requests found
*.sink.console.period = 10
*.sink.console.unit = second
*.source.jvm.class = spark.metrics.source.JvmSource
master.sink.console.period = 20
master.sink.console.unit = minute
*.sink.console.period = 10
*.sink.console.unit = second
test.sink.console.class = spark.metrics.sink.ConsoleSink
test.sink.dummy.class = spark.metrics.sink.DummySink
test.source.dummy.class = spark.metrics.source.DummySource
test.sink.console.period = 20
test.sink.console.unit = minute
......@@ -11,24 +11,7 @@ class MetricsConfigSuite extends FunSuite with BeforeAndAfter {
var filePath: String = _
before {
val prop = new Properties()
prop.setProperty("*.sink.console.period", "10")
prop.setProperty("*.sink.console.unit", "second")
prop.setProperty("*.source.jvm.class", "spark.metrics.source.JvmSource")
prop.setProperty("master.sink.console.period", "20")
prop.setProperty("master.sink.console.unit", "minute")
val dir = new File("/tmp")
filePath = if (dir.isDirectory() && dir.exists() && dir.canWrite()) {
"/tmp/test_metrics.properties"
} else {
"./test_metrics.properties"
}
val os = new FileOutputStream(new File(filePath))
prop.store(os, "for test")
os.close()
filePath = getClass.getClassLoader.getResource("test_metrics_config.properties").getFile()
}
test("MetricsConfig with default properties") {
......@@ -81,12 +64,5 @@ class MetricsConfigSuite extends FunSuite with BeforeAndAfter {
val jmxProps = sinkProps("jmx")
assert(jmxProps.size() === 1)
}
after {
val file = new File(filePath)
if (file.exists()) {
file.delete()
}
}
}
\ No newline at end of file
}
}
......@@ -11,25 +11,7 @@ class MetricsSystemSuite extends FunSuite with BeforeAndAfter {
var filePath: String = _
before {
val props = new Properties()
props.setProperty("*.sink.console.period", "10")
props.setProperty("*.sink.console.unit", "second")
props.setProperty("test.sink.console.class", "spark.metrics.sink.ConsoleSink")
props.setProperty("test.sink.dummy.class", "spark.metrics.sink.DummySink")
props.setProperty("test.source.dummy.class", "spark.metrics.source.DummySource")
props.setProperty("test.sink.console.period", "20")
props.setProperty("test.sink.console.unit", "minute")
val dir = new File("/tmp")
filePath = if (dir.isDirectory() && dir.exists() && dir.canWrite()) {
"/tmp/test_metrics.properties"
} else {
"./test_metrics.properties"
}
val os = new FileOutputStream(new File(filePath))
props.store(os, "for test")
os.close()
filePath = getClass.getClassLoader.getResource("test_metrics_system.properties").getFile()
System.setProperty("spark.metrics.conf.file", filePath)
}
......@@ -54,12 +36,5 @@ class MetricsSystemSuite extends FunSuite with BeforeAndAfter {
val source = new spark.deploy.master.MasterInstrumentation(null)
metricsSystem.registerSource(source)
assert(sources.length === 2)
}
after {
val file = new File(filePath)
if (file.exists()) {
file.delete()
}
}
}
\ No newline at end of file
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment