public abstract class LoadTestBase
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
LoadTestBase.MetricsConfiguration
Utils for the metrics.
|
Modifier and Type | Field and Description |
---|---|
protected static com.google.auth.Credentials |
CREDENTIALS |
protected static com.google.api.gax.core.CredentialsProvider |
CREDENTIALS_PROVIDER |
protected MonitoringClient |
monitoringClient |
protected org.apache.beam.it.common.PipelineLauncher |
pipelineLauncher |
protected org.apache.beam.it.common.PipelineOperator |
pipelineOperator |
protected static java.lang.String |
project |
protected static java.lang.String |
region |
protected java.lang.String |
testName |
TestRule |
watcher |
Constructor and Description |
---|
LoadTestBase() |
Modifier and Type | Method and Description |
---|---|
static java.lang.Double |
calculateAverage(java.util.List<java.lang.Double> values)
Calculate the average from a series.
|
static org.apache.beam.it.common.PipelineOperator.Config |
createConfig(org.apache.beam.it.common.PipelineLauncher.LaunchInfo info,
java.time.Duration timeout) |
protected void |
exportMetricsToBigQuery(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo,
java.util.Map<java.lang.String,java.lang.Double> metrics)
Exports the metrics of given dataflow job to BigQuery.
|
protected java.util.Map<java.lang.String,java.lang.Double> |
getCpuUtilizationMetrics(java.lang.String jobId,
com.google.monitoring.v3.TimeInterval timeInterval)
Computes CPU Utilization metrics of the given job.
|
protected java.util.Map<java.lang.String,java.lang.Double> |
getDataFreshnessMetrics(java.lang.String jobId,
com.google.monitoring.v3.TimeInterval timeInterval)
Computes Data freshness metrics of the given job.
|
protected java.util.Map<java.lang.String,java.lang.Double> |
getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo)
Computes the metrics of the given job using dataflow and monitoring clients.
|
protected java.util.Map<java.lang.String,java.lang.Double> |
getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo,
LoadTestBase.MetricsConfiguration config) |
protected java.util.Map<java.lang.String,java.lang.Double> |
getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo,
java.lang.String inputPcollection)
Computes the metrics of the given job using dataflow and monitoring clients.
|
protected java.util.Map<java.lang.String,java.lang.Double> |
getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo,
java.lang.String inputPcollection,
java.lang.String outputPcollection)
Computes the metrics of the given job using dataflow and monitoring clients.
|
protected java.util.Map<java.lang.String,java.lang.Double> |
getSystemLatencyMetrics(java.lang.String jobId,
com.google.monitoring.v3.TimeInterval timeInterval)
Computes System latency metrics of the given job.
|
protected java.util.Map<java.lang.String,java.lang.Double> |
getThroughputMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo jobInfo,
LoadTestBase.MetricsConfiguration config,
com.google.monitoring.v3.TimeInterval timeInterval)
Computes throughput metrics of the given pcollection in dataflow job.
|
protected com.google.monitoring.v3.TimeInterval |
getWorkerTimeInterval(org.apache.beam.it.common.PipelineLauncher.LaunchInfo info)
Gets the time interval when workers were active to be used by monitoring client.
|
abstract org.apache.beam.it.common.PipelineLauncher |
launcher() |
void |
setUp() |
static void |
setUpClass() |
void |
tearDownLoadTestBase() |
protected boolean |
waitForNumMessages(java.lang.String jobId,
java.lang.String pcollection,
java.lang.Long expectedElements)
Checks if the input PCollection has the expected number of messages.
|
protected static final com.google.auth.Credentials CREDENTIALS
protected static final com.google.api.gax.core.CredentialsProvider CREDENTIALS_PROVIDER
protected static java.lang.String project
protected static java.lang.String region
protected MonitoringClient monitoringClient
protected org.apache.beam.it.common.PipelineLauncher pipelineLauncher
protected org.apache.beam.it.common.PipelineOperator pipelineOperator
protected java.lang.String testName
public TestRule watcher
public static void setUpClass()
public void setUp() throws java.io.IOException
java.io.IOException
public void tearDownLoadTestBase() throws java.io.IOException
java.io.IOException
public abstract org.apache.beam.it.common.PipelineLauncher launcher()
protected void exportMetricsToBigQuery(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo, java.util.Map<java.lang.String,java.lang.Double> metrics)
launchInfo
- Job info of the jobmetrics
- metrics to exportprotected boolean waitForNumMessages(java.lang.String jobId, java.lang.String pcollection, java.lang.Long expectedElements)
jobId
- JobId of the jobpcollection
- the input pcollection nameexpectedElements
- expected number of messagesprotected java.util.Map<java.lang.String,java.lang.Double> getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo, @Nullable java.lang.String inputPcollection, @Nullable java.lang.String outputPcollection) throws java.lang.InterruptedException, java.io.IOException, java.text.ParseException
launchInfo
- Job info of the jobinputPcollection
- input pcollection of the dataflow job to query additional metrics. If
not provided, the metrics will not be calculated.outputPcollection
- output pcollection of the dataflow job to query additional metrics. If
not provided, the metrics will not be calculated.java.io.IOException
- if there is an issue sending the requestjava.text.ParseException
- if timestamp is inaccuratejava.lang.InterruptedException
- thrown if thread is interruptedprotected java.util.Map<java.lang.String,java.lang.Double> getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo, java.lang.String inputPcollection) throws java.text.ParseException, java.lang.InterruptedException, java.io.IOException
launchInfo
- Job info of the jobinputPcollection
- input pcollection of the dataflow job to query additional metrics. If
not provided, the metrics will not be calculated.java.io.IOException
- if there is an issue sending the requestjava.text.ParseException
- if timestamp is inaccuratejava.lang.InterruptedException
- thrown if thread is interruptedprotected java.util.Map<java.lang.String,java.lang.Double> getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo) throws java.text.ParseException, java.lang.InterruptedException, java.io.IOException
launchInfo
- Job info of the jobjava.io.IOException
- if there is an issue sending the requestjava.text.ParseException
- if timestamp is inaccuratejava.lang.InterruptedException
- thrown if thread is interruptedprotected java.util.Map<java.lang.String,java.lang.Double> getMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo launchInfo, LoadTestBase.MetricsConfiguration config) throws java.io.IOException, java.lang.InterruptedException, java.text.ParseException
java.io.IOException
java.lang.InterruptedException
java.text.ParseException
protected java.util.Map<java.lang.String,java.lang.Double> getCpuUtilizationMetrics(java.lang.String jobId, com.google.monitoring.v3.TimeInterval timeInterval)
jobId
- dataflow job idtimeInterval
- interval for the monitoring queryprotected java.util.Map<java.lang.String,java.lang.Double> getThroughputMetrics(org.apache.beam.it.common.PipelineLauncher.LaunchInfo jobInfo, LoadTestBase.MetricsConfiguration config, com.google.monitoring.v3.TimeInterval timeInterval)
jobInfo
- dataflow job LaunchInfoconfig
- the timeInterval
- interval for the monitoring queryprotected java.util.Map<java.lang.String,java.lang.Double> getDataFreshnessMetrics(java.lang.String jobId, com.google.monitoring.v3.TimeInterval timeInterval)
jobId
- dataflow job idtimeInterval
- interval for the monitoring queryprotected java.util.Map<java.lang.String,java.lang.Double> getSystemLatencyMetrics(java.lang.String jobId, com.google.monitoring.v3.TimeInterval timeInterval)
jobId
- dataflow job idtimeInterval
- interval for the monitoring queryprotected com.google.monitoring.v3.TimeInterval getWorkerTimeInterval(org.apache.beam.it.common.PipelineLauncher.LaunchInfo info) throws java.text.ParseException
java.text.ParseException
public static java.lang.Double calculateAverage(java.util.List<java.lang.Double> values)
values
- the input series.public static org.apache.beam.it.common.PipelineOperator.Config createConfig(org.apache.beam.it.common.PipelineLauncher.LaunchInfo info, java.time.Duration timeout)