-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
The current implementation allows the loading of configuration data from a JSON file.
Under the hood, it is loaded and provided as IConfiguration to the NBomberContext.
It would be great to have the ability to load this data from IConfiguration directly. It will allow to pass parameters from environment variables or command line arguments,
Currently, I have developed the following extension method:
internal static class InfluxDbSinkExtensions
{
internal static NBomberContext WithInfluxDbSink(this NBomberContext context, IConfiguration config)
{
// It is expected that the configuration may contain values like: InfluxDBSink:Url, InfluxDBSink:Database
var influxDbConfig = config.GetSection("InfluxDBSink").Get<InfluxDbSinkConfig>();
if (influxDbConfig == null)
return context; // InfluxDb is not configured.
// The configuration values are present, and we must path that IConfiguration instance to NBomberContext.
// Since NBomberContext is immutable, we must manually create a new instance. The rest of the properties need to be passed as is.
var newContext = new NBomberContext(
context.TestSuite,
context.TestName,
context.RegisteredScenarios,
context.NBomberConfig,
FSharpOption<IConfiguration>.Some(config),
context.CreateLoggerConfig,
context.Reporting,
context.WorkerPlugins,
context.TargetScenarios,
context.MinimumLogLevel,
context.EnableStopTestForcibly,
context.License,
context.SessionId,
context.EnableLocalDevCluster,
context.ClusterId,
context.AgentsCount,
context.AgentGroup,
context.NodeType,
context.ScenarioCompletionTimeout,
context.DisplayConsoleMetrics
);
return newContext.WithReportingSinks(new InfluxDBSink());
}
}
Would it be possible to include something similar out of the box?
Thank you in advance
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels