-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aws test container #134
Aws test container #134
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For 1) I agree that you can use an env var to set the AWS endpoint. Something like MAGPIE_AWS_ENDPOINT
. My first thought is to create a static utility method that will return the endpoint (defaulting to aws.amazon.com if not specified). Then each service will pass along that result to it's constructor.
For 3) Don't sweat the localstack demo env. We'll cross that bridge when we get to it.
45083bc
to
defe72e
Compare
magpie-aws/src/main/java/io/openraven/magpie/plugins/aws/discovery/services/S3Discovery.java
Outdated
Show resolved
Hide resolved
magpie-aws/src/main/java/io/openraven/magpie/plugins/aws/discovery/AWSUtils.java
Outdated
Show resolved
Hide resolved
magpie-aws/src/main/java/io/openraven/magpie/plugins/aws/discovery/AWSUtils.java
Outdated
Show resolved
Hide resolved
defe72e
to
d8c910d
Compare
Added:
|
0c73d55
to
d1388b1
Compare
d1388b1
to
506709e
Compare
} | ||
|
||
@Test | ||
public void testEC2Discovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whenRunningEc2DiscoveryShouldReturnInstanceEipSecurityGroupVolumeAndSnapshotInformation
It's probably good idea to split this test into 5. Each testing one thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got your point @PrzemyslawTusinski . We rather have here a complete testing for chosen component from magpie discovery perspective, instead of the unit testing when we could write tests isolated for various corner cases.
Splitting works good but we are going to expose our private methods for component discovery of the various aspects.
For example how we made with IAM - but I dont really like to change private method to protected just for the test availability.
I threat those tests as e2e AWS component discovery based on localstack. It like an IT with WireMocks when you passing from the controller request to database layer and back verifying the response.
In any case I propose to change method naming convention here once we will extend them with additional coverage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't meant exposing private methods.
I meant running full discovery in each test case, then during asset phase assert only one resource on each test case
} | ||
|
||
@Test | ||
public void testDynamoDBDiscovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whenDiscoveringDynamoDbTablesShouldReturnProperContentInfo
} | ||
|
||
@Test | ||
public void testKMSDiscovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming?
} | ||
|
||
@Test | ||
public void testCloudWatchDiscovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming?
private ArgumentCaptor<MagpieEnvelope> envelopeCapture; | ||
|
||
@Test | ||
public void testAccountDiscovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming?
} | ||
|
||
@Test | ||
public void testRoute53Discovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming?
} | ||
|
||
@Test | ||
public void testS3Discovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming?
} | ||
|
||
@Test | ||
public void testSNSDiscovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming?
} | ||
|
||
@Test | ||
public void testSecretManagerDiscovery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better naming?
assertTopic(invocations.get(0)); | ||
assertSubscription(invocations.get(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider splitting this to 2 test cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be possible only if we will expose methods discoverTopics
and discoverSubscriptions
.
Not sure if we want it for test purpose. Initially I was designing cumulative approach to test input/output for available exposed method.
This decrease execution time and leading to the comparable coverage.
But it could fail because issue in either topic or subscription - at this point of IT testing that should be acceptable.
I will propose separate refactoring if required later.
Builded and tested against the real AWS Services |
Preliminary code which expose the current problems during test containers setup
DynamoDB discovery is working, you could try it.
At the moment we are creating dependencies for our selves (clients), so that it becomes difficult to inject localstack clients into the code. We need to expose private methods. But that also not working. Even deeper we also create such dependancy (S3 discovery is not working due to that perspective)
Otherwise with current clients we are trying to reach the real AWS.
1.1. I'm thinking about lightweight ServiceDiscovery pattern, but we need to keep clients being configured for different Regions being requested (e.g DynamoDB_AWS_GLOBAL / DynamoDB_US_WEST_1 )
Seems like AWS Java SDK doesn't provide possibility to override AWS Endpoint globally for all clients link
For a demo purpose we could setup localstack separately but we need to bypass localstack docker URL to reach it. Meanwhile there no possibility for that in code
Proposal:
We could create our AWS Clients based on env variable being passed on the stage of execution - > if nothing passed fallback to the default one - https://aws.amazon.com/
[To not merge yet]