aws-greengrass / aws-greengrass-client-device-auth

Apache License 2.0
2 stars 3 forks source link

chore: deflake rest of MetricsEmitterTest #421

Closed jcosentino11 closed 10 months ago

jcosentino11 commented 10 months ago

Issue #, if available:

Description of changes:

Continuation of https://github.com/aws-greengrass/aws-greengrass-client-device-auth/pull/420, extended to the whole MetricsEmitterTest.

Previously we waited for emitMetrics to be called to signal a metric was reported, but even with https://github.com/aws-greengrass/aws-greengrass-client-device-auth/pull/420 there is still a race between calling the API and emitMetrics (GIVEN_kernelRunningWithMetricsConfig_WHEN_subscribeToCertificateUpdate_THEN_successMetricEmitted, for example was failing unit tests when attempting to make the same change).

To ignore the race, we can capture the first (non empty) list of metrics, and wait for metric emitter to run at least another cycle and verify no extra methods are emitted. This would verify that for one API call, we get exactly one metric emit.

Why is this change necessary:

How was this change tested:

Any additional information or context required to review the change:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

github-actions[bot] commented 10 months ago

Code Coverage Report

File Coverage
All files 73% :white_check_mark:
com.aws.greengrass.clientdevices.auth.PermissionEvaluationUtils 77% :white_check_mark:
com.aws.greengrass.clientdevices.auth.CertificateManager 88% :white_check_mark:
com.aws.greengrass.clientdevices.auth.ClientDevicesAuthService 79% :white_check_mark:
com.aws.greengrass.clientdevices.auth.DeviceAuthClient 73% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.ClientCertificateGenerator 95% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.CertificateHelper 74% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.CertificateStore 72% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.CertificateExpiryMonitor 77% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.ServerCertificateGenerator 93% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.CertificateGenerator 70% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.CertificateExpiryMonitor$CertRotationDecider 90% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.usecases.VerifyIotCertificate 94% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.usecases.VerifyThingAttachedToCertificate 89% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.usecases.CreateIoTThingSession 67% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.usecases.VerifyCertificateValidityPeriod 88% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.infra.BackgroundCertificateRefresh 82% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.infra.ThingRegistry 92% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.usecases.ConfigureManagedCertificateAuthority 85% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.usecases.ConfigureCustomCertificateAuthority 83% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.usecases.RegisterCertificateAuthorityUseCase 65% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.MetricsConfiguration 83% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.GroupManager 89% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.CAConfiguration 96% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.RuntimeConfiguration 83% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.SecurityConfiguration 80% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.GroupDefinition 75% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.ExpressionVisitor 84% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.GroupConfiguration 92% :white_check_mark:
com.aws.greengrass.clientdevices.auth.api.ClientDevicesAuthServiceApi 85% :white_check_mark:
com.aws.greengrass.clientdevices.auth.api.GetCertificateRequestWithGenerator 75% :white_check_mark:
com.aws.greengrass.clientdevices.auth.api.UseCases 71% :white_check_mark:
com.aws.greengrass.clientdevices.auth.session.attribute.WildcardSuffixAttribute 96% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.IotAuthClient$Default 56% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.Thing 85% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.Certificate 74% :white_check_mark:
com.aws.greengrass.clientdevices.auth.iot.GreengrassV2DataClientFactory 18% :x:
com.aws.greengrass.clientdevices.auth.iot.CertificateRegistry 95% :white_check_mark:
com.aws.greengrass.clientdevices.auth.infra.NetworkStateProvider$Default 83% :white_check_mark:
com.aws.greengrass.ipc.IPCUtils 83% :white_check_mark:
com.aws.greengrass.ipc.VerifyClientDeviceIdentityOperationHandler 60% :white_check_mark:
com.aws.greengrass.ipc.GetClientDeviceAuthTokenOperationHandler 83% :white_check_mark:
com.aws.greengrass.ipc.AuthorizeClientDeviceActionOperationHandler 79% :white_check_mark:
com.aws.greengrass.ipc.SubscribeToCertificateUpdatesOperationHandler 81% :white_check_mark:
com.aws.greengrass.clientdevices.auth.session.SessionConfig 92% :white_check_mark:
com.aws.greengrass.clientdevices.auth.session.SessionManager 88% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.handlers.CAConfigurationChangedHandler 93% :white_check_mark:
com.aws.greengrass.clientdevices.auth.certificate.handlers.CertificateRotationHandler 96% :white_check_mark:
com.aws.greengrass.clientdevices.auth.metrics.handlers.SessionCreationEventHandler 88% :white_check_mark:
com.aws.greengrass.clientdevices.auth.metrics.handlers.MetricsConfigurationChangedHandler 70% :white_check_mark:
com.aws.greengrass.clientdevices.auth.metrics.handlers.AuthorizeClientDeviceActionsMetricHandler 88% :white_check_mark:
com.aws.greengrass.clientdevices.auth.metrics.handlers.VerifyClientDeviceIdentityEventHandler 88% :white_check_mark:
com.aws.greengrass.clientdevices.auth.metrics.handlers.CertificateSubscriptionEventHandler 83% :white_check_mark:
com.aws.greengrass.clientdevices.auth.util.ResizableLinkedBlockingQueue 90% :white_check_mark:
com.aws.greengrass.clientdevices.auth.util.ParseIPAddress 90% :white_check_mark:
com.aws.greengrass.clientdevices.auth.connectivity.CISShadowMonitor$SucceedOnceOperation 88% :white_check_mark:
com.aws.greengrass.clientdevices.auth.connectivity.CISShadowMonitor 79% :white_check_mark:
com.aws.greengrass.clientdevices.auth.connectivity.CISShadowMonitor$ProcessCISShadowTask 76% :white_check_mark:
com.aws.greengrass.clientdevices.auth.connectivity.CISShadowMonitor$CISShadowTaskQueue 83% :white_check_mark:
com.aws.greengrass.clientdevices.auth.connectivity.HostAddress 67% :white_check_mark:
com.aws.greengrass.clientdevices.auth.connectivity.CISShadowMonitor$CISShadowTaskExecutor 80% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.TokenMgrError 22% :x:
com.aws.greengrass.clientdevices.auth.configuration.parser.RuleExpressionTokenManager 61% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.ASTStart 33% :x:
com.aws.greengrass.clientdevices.auth.configuration.parser.ASTAnd 67% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.Token 58% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.RuleExpressionDefaultVisitor 0% :x:
com.aws.greengrass.clientdevices.auth.configuration.parser.ASTOr 67% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.SimpleCharStream 28% :x:
com.aws.greengrass.clientdevices.auth.configuration.parser.RuleExpressionTreeConstants 0% :x:
com.aws.greengrass.clientdevices.auth.configuration.parser.JJTRuleExpressionState 67% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.ASTThing 67% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.RuleExpression 63% :white_check_mark:
com.aws.greengrass.clientdevices.auth.configuration.parser.SimpleNode 27% :x:

Minimum allowed coverage is 50%

Generated by :monkey: cobertura-action against c71327fdaee7be82fe86affe906a16fad8a8f90b

github-actions[bot] commented 10 months ago

Benchmark Results

Benchmark Score
com.aws.greengrass.clientdevices.auth.benchmark.AuthorizationBenchmarks.GIVEN_policy_with_thing_name_variable_WHEN_auth_request_THEN_successful_auth 758292.94 ops/s
com.aws.greengrass.clientdevices.auth.benchmark.AuthorizationBenchmarks.GIVEN_single_group_permission_WHEN_simple_auth_request_THEN_successful_auth 1068751.23 ops/s