use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.
the class TaskThreadPoolTest method constructor.
@Test
public void constructor() {
ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
expect(scrapeConfig.getNumTaskThreads()).andReturn(2);
replayAll();
new TaskThreadPool(scrapeConfigProvider);
verifyAll();
}
use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.
the class LambdaCapacityExporterTest method setup.
@BeforeEach
public void setup() {
ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
namespaceConfig = mock(NamespaceConfig.class);
awsClientProvider = mock(AWSClientProvider.class);
lambdaClient = mock(LambdaClient.class);
metricNameUtil = mock(MetricNameUtil.class);
metricCollector = mock(BasicMetricCollector.class);
functionScraper = mock(LambdaFunctionScraper.class);
resourceTagHelper = mock(ResourceTagHelper.class);
resource = mock(Resource.class);
sampleBuilder = mock(MetricSampleBuilder.class);
sample = mock(Sample.class);
familySamples = mock(Collector.MetricFamilySamples.class);
resetAll();
testClass = new LambdaCapacityExporter(scrapeConfigProvider, awsClientProvider, metricNameUtil, sampleBuilder, functionScraper, resourceTagHelper, new RateLimiter(metricCollector));
expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
expect(scrapeConfig.getLambdaConfig()).andReturn(Optional.of(namespaceConfig));
expect(metricNameUtil.getLambdaMetric("available_concurrency")).andReturn("available");
expect(metricNameUtil.getLambdaMetric("requested_concurrency")).andReturn("requested");
expect(metricNameUtil.getLambdaMetric("allocated_concurrency")).andReturn("allocated");
expect(metricNameUtil.getLambdaMetric("timeout_seconds")).andReturn("timeout");
expect(metricNameUtil.getLambdaMetric("memory_limit_mb")).andReturn("memory_limit");
expect(metricNameUtil.getLambdaMetric("account_limit")).andReturn("limit");
expect(metricNameUtil.getLambdaMetric("reserved_concurrency")).andReturn("reserved");
fn1 = LambdaFunction.builder().account("account1").region("region1").arn("arn1").name("fn1").memoryMB(128).timeoutSeconds(120).build();
fn1Labels = ImmutableMap.of("region", "region1", "d_function_name", "fn1", "job", "fn1", "cw_namespace", "AWS/Lambda", SCRAPE_ACCOUNT_ID_LABEL, "account1");
fn1VersionLabels = new HashMap<>(ImmutableMap.of("region", "region1", "d_function_name", "fn1", "d_executed_version", "1", "job", "fn1", "cw_namespace", "AWS/Lambda"));
fn1VersionLabels.put(SCRAPE_ACCOUNT_ID_LABEL, "account1");
fn2 = LambdaFunction.builder().account("account2").region("region2").arn("arn2").name("fn2").memoryMB(128).timeoutSeconds(60).build();
fn2Labels = ImmutableMap.of("region", "region2", "d_function_name", "fn2", "job", "fn2", "cw_namespace", "AWS/Lambda", SCRAPE_ACCOUNT_ID_LABEL, "account2");
fn2ResourceLabels = new HashMap<>(ImmutableMap.of("region", "region2", "d_function_name", "fn2", "d_resource", "green", "job", "fn2", "cw_namespace", "AWS/Lambda"));
fn2ResourceLabels.put(SCRAPE_ACCOUNT_ID_LABEL, "account2");
}
use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.
the class LambdaInvokeConfigExporterTest method setup.
@BeforeEach
public void setup() {
fnScraper = mock(LambdaFunctionScraper.class);
awsClientProvider = mock(AWSClientProvider.class);
lambdaClient = mock(LambdaClient.class);
metricNameUtil = mock(MetricNameUtil.class);
ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
NamespaceConfig namespaceConfig = mock(NamespaceConfig.class);
resourceMapper = mock(ResourceMapper.class);
resource = mock(Resource.class);
metricSampleBuilder = mock(MetricSampleBuilder.class);
sample = mock(Collector.MetricFamilySamples.Sample.class);
metricCollector = mock(BasicMetricCollector.class);
testClass = new LambdaInvokeConfigExporter(fnScraper, awsClientProvider, metricNameUtil, scrapeConfigProvider, resourceMapper, metricSampleBuilder, new RateLimiter(metricCollector));
expect(scrapeConfig.getLambdaConfig()).andReturn(Optional.of(namespaceConfig));
expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
expect(metricNameUtil.getMetricPrefix(CWNamespace.lambda.getNamespace())).andReturn("prefix");
}
use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.
the class EC2ToEBSVolumeExporterTest method setup.
@BeforeEach
public void setup() {
AccountIDProvider accountIDProvider = mock(AccountIDProvider.class);
AWSClientProvider awsClientProvider = mock(AWSClientProvider.class);
ec2Client = mock(Ec2Client.class);
ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
metricCollector = mock(BasicMetricCollector.class);
testClass = new EC2ToEBSVolumeExporter(accountIDProvider, scrapeConfigProvider, awsClientProvider, new RateLimiter(metricCollector));
expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig);
expect(scrapeConfig.getRegions()).andReturn(ImmutableSet.of("region"));
expect(awsClientProvider.getEc2Client("region")).andReturn(ec2Client);
expect(accountIDProvider.getAccountId()).andReturn("account").anyTimes();
}
use of ai.asserts.aws.cloudwatch.config.ScrapeConfigProvider in project aws-cloudwatch-exporter by asserts.
the class LBToLambdaRoutingBuilderTest method setup.
@BeforeEach
public void setup() {
AccountIDProvider accountIDProvider = mock(AccountIDProvider.class);
ScrapeConfigProvider scrapeConfigProvider = mock(ScrapeConfigProvider.class);
ScrapeConfig scrapeConfig = mock(ScrapeConfig.class);
AWSClientProvider awsClientProvider = mock(AWSClientProvider.class);
TargetGroupLBMapProvider targetGroupLBMapProvider = mock(TargetGroupLBMapProvider.class);
metricCollector = mock(BasicMetricCollector.class);
elbV2Client = mock(ElasticLoadBalancingV2Client.class);
resourceMapper = mock(ResourceMapper.class);
targetResource = mock(Resource.class);
lbRsource = mock(Resource.class);
lambdaResource = mock(Resource.class);
testClass = new LBToLambdaRoutingBuilder(accountIDProvider, scrapeConfigProvider, awsClientProvider, new RateLimiter(metricCollector), resourceMapper, targetGroupLBMapProvider);
expect(accountIDProvider.getAccountId()).andReturn("account").anyTimes();
expect(scrapeConfigProvider.getScrapeConfig()).andReturn(scrapeConfig).anyTimes();
expect(scrapeConfig.getRegions()).andReturn(ImmutableSet.of("region")).anyTimes();
expect(awsClientProvider.getELBV2Client("region")).andReturn(elbV2Client).anyTimes();
expect(targetGroupLBMapProvider.getTgToLB()).andReturn(ImmutableMap.of(targetResource, lbRsource));
}
Aggregations