This repository was archived by the owner on Mar 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make Conformity Monkey Notify Based on owner tag value #257
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/test/java/com/netflix/simianarmy/aws/conformity/TestASGOwnerEmailTag.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // CHECKSTYLE IGNORE Javadoc | ||
| package com.netflix.simianarmy.aws.conformity; | ||
|
|
||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import com.amazonaws.services.autoscaling.model.AutoScalingGroup; | ||
| import com.amazonaws.services.autoscaling.model.SuspendedProcess; | ||
| import com.amazonaws.services.autoscaling.model.TagDescription; | ||
|
|
||
| import com.google.common.collect.Maps; | ||
|
|
||
| import com.netflix.simianarmy.aws.conformity.crawler.AWSClusterCrawler; | ||
| import com.netflix.simianarmy.basic.BasicConfiguration; | ||
| import com.netflix.simianarmy.basic.conformity.BasicConformityMonkeyContext; | ||
| import com.netflix.simianarmy.conformity.Cluster; | ||
| import com.netflix.simianarmy.client.aws.AWSClient; | ||
|
|
||
| import junit.framework.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.List; | ||
| import java.util.LinkedList; | ||
| import java.util.Properties; | ||
|
|
||
| public class TestASGOwnerEmailTag { | ||
|
|
||
| private static final String ASG1 = "asg1"; | ||
| private static final String ASG2 = "asg2"; | ||
| private static final String OWNER_TAG_KEY = "owner"; | ||
| private static final String OWNER_TAG_VALUE = "tyler@paperstreet.com"; | ||
| private static final String REGION = "eu-west-1"; | ||
|
|
||
| @Test | ||
| public void testForOwnerTag() { | ||
| Properties properties = new Properties(); | ||
| BasicConformityMonkeyContext ctx = new BasicConformityMonkeyContext(); | ||
|
|
||
| List<AutoScalingGroup> asgList = createASGList(); | ||
| String[] asgNames = {ASG1, ASG2}; | ||
|
|
||
| AWSClient awsMock = createMockAWSClient(asgList, asgNames); | ||
| Map<String, AWSClient> regionToAwsClient = Maps.newHashMap(); | ||
| regionToAwsClient.put("us-east-1", awsMock); | ||
| AWSClusterCrawler clusterCrawler = new AWSClusterCrawler(regionToAwsClient, new BasicConfiguration(properties)); | ||
|
|
||
| List<Cluster> clusters = clusterCrawler.clusters(asgNames); | ||
|
|
||
| Assert.assertTrue(OWNER_TAG_VALUE.equalsIgnoreCase(clusters.get(0).getOwnerEmail())); | ||
| Assert.assertNull(clusters.get(1).getOwnerEmail()); | ||
| } | ||
|
|
||
| private List<AutoScalingGroup> createASGList() { | ||
| List<AutoScalingGroup> asgList = new LinkedList<AutoScalingGroup>(); | ||
| asgList.add(makeASG(ASG1, OWNER_TAG_VALUE)); | ||
| asgList.add(makeASG(ASG2, null)); | ||
| return asgList; | ||
| } | ||
|
|
||
| private AutoScalingGroup makeASG(String asgName, String ownerEmail) { | ||
| TagDescription tag = new TagDescription().withKey(OWNER_TAG_KEY).withValue(ownerEmail); | ||
| AutoScalingGroup asg = new AutoScalingGroup() | ||
| .withAutoScalingGroupName(asgName) | ||
| .withTags(tag); | ||
| return asg; | ||
| } | ||
|
|
||
| private AWSClient createMockAWSClient(List<AutoScalingGroup> asgList, String... asgNames) { | ||
| AWSClient awsMock = mock(AWSClient.class); | ||
| when(awsMock.describeAutoScalingGroups(asgNames)).thenReturn(asgList); | ||
| return awsMock; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not following the logic for this test: an awsMock was created and setup but never used.
It appears this test just looks to see if the owner tags are present in the test list rather then testing if the AWSClusterCrawler is behaving as expected.