这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Mar 4, 2021. It is now read-only.

Update tests for AWS 17 characters resources #235

Merged
merged 1 commit into from
Feb 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public TestSimpleDBJanitorResourceTracker() {

@Test
public void testAddResource() {
String id = "i-1234567";
String id = "i-12345678901234567";
AWSResourceType resourceType = AWSResourceType.INSTANCE;
Resource.CleanupState state = Resource.CleanupState.MARKED;
String description = "This is a test resource.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testSnapshotsWithNullIds() {
public void testSnapshotsWithIds() {
Date startTime = new Date();
List<Snapshot> snapshotList = createSnapshotList(startTime);
String[] ids = {"snap-123456780", "snap-123456781"};
String[] ids = {"snap-12345678901234567", "snap-12345678901234567"};
EBSSnapshotJanitorCrawler crawler = new EBSSnapshotJanitorCrawler(createMockAWSClient(snapshotList, ids));
List<Resource> resources = crawler.resources(ids);
verifySnapshotList(resources, snapshotList, startTime);
Expand Down Expand Up @@ -107,8 +107,8 @@ private AWSClient createMockAWSClient(List<Snapshot> snapshotList, String... ids

private List<Snapshot> createSnapshotList(Date startTime) {
List<Snapshot> snapshotList = new LinkedList<Snapshot>();
snapshotList.add(mkSnapshot("snap-123456780", startTime));
snapshotList.add(mkSnapshot("snap-123456781", startTime));
snapshotList.add(mkSnapshot("snap-12345678901234567", startTime));
snapshotList.add(mkSnapshot("snap-12345678901234567", startTime));
return snapshotList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void testVolumesWithNullIds() {
public void testVolumesWithIds() {
Date createTime = new Date();
List<Volume> volumeList = createVolumeList(createTime);
String[] ids = {"vol-123456780", "vol-123456781"};
String[] ids = {"vol-12345678901234567", "vol-12345678901234567"};
EBSVolumeJanitorCrawler crawler = new EBSVolumeJanitorCrawler(createMockAWSClient(volumeList, ids));
List<Resource> resources = crawler.resources(ids);
verifyVolumeList(resources, volumeList, createTime);
Expand Down Expand Up @@ -107,8 +107,8 @@ private AWSClient createMockAWSClient(List<Volume> volumeList, String... ids) {

private List<Volume> createVolumeList(Date createTime) {
List<Volume> volumeList = new LinkedList<Volume>();
volumeList.add(mkVolume("vol-123456780", createTime));
volumeList.add(mkVolume("vol-123456781", createTime));
volumeList.add(mkVolume("vol-12345678901234567", createTime));
volumeList.add(mkVolume("vol-12345678901234567", createTime));
return volumeList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testInstancesWithNullIds() {
public void testInstancesWithIds() {
List<AutoScalingInstanceDetails> instanceDetailsList = createInstanceDetailsList();
List<Instance> instanceList = createInstanceList();
String[] ids = {"i-123456780", "i-123456780"};
String[] ids = {"i-12345678901234560", "i-12345678901234561"};
AWSClient awsMock = createMockAWSClient(instanceDetailsList, instanceList, ids);
InstanceJanitorCrawler crawler = new InstanceJanitorCrawler(awsMock);
List<Resource> resources = crawler.resources(ids);
Expand Down Expand Up @@ -125,8 +125,8 @@ private AWSClient createMockAWSClient(List<AutoScalingInstanceDetails> instanceD

private List<AutoScalingInstanceDetails> createInstanceDetailsList() {
List<AutoScalingInstanceDetails> instanceList = new LinkedList<AutoScalingInstanceDetails>();
instanceList.add(mkInstanceDetails("i-123456780", "asg1"));
instanceList.add(mkInstanceDetails("i-123456781", "asg2"));
instanceList.add(mkInstanceDetails("i-12345678901234560", "asg1"));
instanceList.add(mkInstanceDetails("i-12345678901234561", "asg2"));
return instanceList;
}

Expand All @@ -136,8 +136,8 @@ private AutoScalingInstanceDetails mkInstanceDetails(String instanceId, String a

private List<Instance> createInstanceList() {
List<Instance> instanceList = new LinkedList<Instance>();
instanceList.add(mkInstance("i-123456780"));
instanceList.add(mkInstance("i-123456781"));
instanceList.add(mkInstance("i-12345678901234560"));
instanceList.add(mkInstance("i-12345678901234561"));
return instanceList;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testASGWithInstances() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_LC_NAME, "launchConfig");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "i-1,i-2");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "123456789012345671,i-123456789012345672");
int launchConfiguAgeThreshold = 60;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
Expand Down Expand Up @@ -180,7 +180,7 @@ public void testNullCalendar() {

@Test
public void testNonASGResource() {
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE);
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
OldEmptyASGRule rule = new OldEmptyASGRule(new TestMonkeyCalendar(), 3, 60, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void testEmptyASGSuspendedLessThanThreshold() {
public void testASGWithInstances() {
Resource resource = new AWSResource().withId("asg1").withResourceType(AWSResourceType.ASG);
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_MAX_SIZE, "2");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "i-1,i-2");
resource.setAdditionalField(ASGJanitorCrawler.ASG_FIELD_INSTANCES, "123456789012345671,i-123456789012345672");
int suspensionAgeThreshold = 2;
MonkeyCalendar calendar = new TestMonkeyCalendar();
DateTime now = new DateTime(calendar.now().getTimeInMillis());
Expand Down Expand Up @@ -177,7 +177,7 @@ public void testSuspensionTimeIncorrectFormat() {

@Test
public void testNonASGResource() {
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE);
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
SuspendedASGRule rule = new SuspendedASGRule(new TestMonkeyCalendar(), 3, 2, new DummyASGInstanceValidator());
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class TestUntaggedRule {
@Test
public void testUntaggedInstanceWithOwner() {
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE)
.withOwnerEmail("owner@foo.com");
resource.setTag("tag1", "value1");
((AWSResource) resource).setAWSResourceState("running");
Expand All @@ -57,7 +57,7 @@ public void testUntaggedInstanceWithOwner() {
@Test
public void testUntaggedInstanceWithoutOwner() {
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE);
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
resource.setTag("tag1", "value1");
((AWSResource) resource).setAWSResourceState("running");
Set<String> tags = new HashSet<String>();
Expand All @@ -72,7 +72,7 @@ public void testUntaggedInstanceWithoutOwner() {

@Test
public void testTaggedInstance() {
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE);
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
resource.setTag("tag1", "value1");
resource.setTag("tag2", "value2");
((AWSResource) resource).setAWSResourceState("running");
Expand All @@ -90,7 +90,7 @@ public void testUntaggedResource() {
DateTime now = DateTime.now();
Resource imageResource = new AWSResource().withId("ami-123123").withResourceType(AWSResourceType.IMAGE);
Resource asgResource = new AWSResource().withId("my-cool-asg").withResourceType(AWSResourceType.ASG);
Resource ebsSnapshotResource = new AWSResource().withId("snap-123123").withResourceType(AWSResourceType.EBS_SNAPSHOT);
Resource ebsSnapshotResource = new AWSResource().withId("snap-12345678901234567").withResourceType(AWSResourceType.EBS_SNAPSHOT);
Resource lauchConfigurationResource = new AWSResource().withId("my-cool-launch-configuration").withResourceType(AWSResourceType.LAUNCH_CONFIG);
Set<String> tags = new HashSet<String>();
tags.add("tag1");
Expand All @@ -113,7 +113,7 @@ public void testResourceWithExpectedTerminationTimeSet() {
DateTime now = DateTime.now();
Date oldTermDate = new Date(now.plusDays(10).getMillis());
String oldTermReason = "Foo";
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE)
.withExpectedTerminationTime(oldTermDate)
.withTerminationReason(oldTermReason);
((AWSResource) resource).setAWSResourceState("running");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class TestOrphanedInstanceRule {
public void testOrphanedInstancesWithOwner() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE)
.withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()))
.withOwnerEmail("owner@foo.com");
((AWSResource) resource).setAWSResourceState("running");
Expand All @@ -55,7 +55,7 @@ public void testOrphanedInstancesWithOwner() {
public void testOrphanedInstancesWithoutOwner() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE)
.withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()));
((AWSResource) resource).setAWSResourceState("running");
int retentionDaysWithOwner = 4;
Expand All @@ -69,7 +69,7 @@ public void testOrphanedInstancesWithoutOwner() {
@Test
public void testOrphanedInstancesWithoutLaunchTime() {
int ageThreshold = 5;
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE);
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
((AWSResource) resource).setAWSResourceState("running");
int retentionDaysWithOwner = 4;
int retentionDaysWithoutOwner = 8;
Expand All @@ -83,7 +83,7 @@ public void testOrphanedInstancesWithoutLaunchTime() {
public void testOrphanedInstancesWithLaunchTimeNotExpires() {
int ageThreshold = 5;
DateTime now = DateTime.now();
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE)
.withLaunchTime(new Date(now.minusDays(ageThreshold - 1).getMillis()));
((AWSResource) resource).setAWSResourceState("running");
int retentionDaysWithOwner = 4;
Expand All @@ -97,7 +97,7 @@ public void testOrphanedInstancesWithLaunchTimeNotExpires() {
@Test
public void testNonOrphanedInstances() {
int ageThreshold = 5;
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE)
.setAdditionalField(InstanceJanitorCrawler.INSTANCE_FIELD_ASG_NAME, "asg1");
((AWSResource) resource).setAWSResourceState("running");
int retentionDaysWithOwner = 4;
Expand All @@ -114,7 +114,7 @@ public void testResourceWithExpectedTerminationTimeSet() {
Date oldTermDate = new Date(now.plusDays(10).getMillis());
String oldTermReason = "Foo";
int ageThreshold = 5;
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE)
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE)
.withLaunchTime(new Date(now.minusDays(ageThreshold + 1).getMillis()))
.withExpectedTerminationTime(oldTermDate)
.withTerminationReason(oldTermReason);
Expand Down Expand Up @@ -165,7 +165,7 @@ public void testNonInstanceResource() {

@Test
public void testNonRunningInstance() {
Resource resource = new AWSResource().withId("i-123").withResourceType(AWSResourceType.INSTANCE);
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
((AWSResource) resource).setAWSResourceState("stopping");
OrphanedInstanceRule rule = new OrphanedInstanceRule(new TestMonkeyCalendar(), 0, 0, 0);
Assert.assertTrue(rule.isValid(resource));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void testNullCalendar() {

@Test
public void testNonLaunchConfigResource() {
Resource resource = new AWSResource().withId("i-12345678").withResourceType(AWSResourceType.INSTANCE);
Resource resource = new AWSResource().withId("i-12345678901234567").withResourceType(AWSResourceType.INSTANCE);
OldUnusedLaunchConfigRule rule = new OldUnusedLaunchConfigRule(new TestMonkeyCalendar(), 3, 60);
Assert.assertTrue(rule.isValid(resource));
Assert.assertNull(resource.getExpectedTerminationTime());
Expand Down
Loading