Skip to content

Commit

Permalink
adding details to test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ina-stoyanova committed Sep 30, 2020
1 parent 767aa3d commit 4faa24e
Showing 1 changed file with 36 additions and 18 deletions.
54 changes: 36 additions & 18 deletions aws/ecs_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,26 @@ func TestCanCreateAndListEcsCluster(t *testing.T) {

// Test we can create a cluster, tag it, and then find the cluster
func TestCanTagEcsClusterAndFilterByTag(t *testing.T) {
t.Parallel()

region := "eu-west-1"
awsSession, err := session.NewSession(&awsgo.Config{
Region: awsgo.String(region),
})
if err != nil {
assert.Fail(t, errors.WithStackTrace(err).Error())
}

clusterName := "test-ina"
cluster := createEcsFargateCluster(t, awsSession, clusterName)
defer deleteEcsCluster(awsSession, cluster)

clusterArns, err := getAllEcsClusters(awsSession)
if err != nil {
assert.Failf(t, "Unable to fetch clusters: %s", err.Error())
}

assert.Contains(t, clusterArns, cluster.ClusterArn)
// create a cluster without tag
// get cluster
// tag with "first_seen" : "current timestamp"
Expand All @@ -52,8 +72,24 @@ func TestWontTagEcsClusterWithTag(t *testing.T) {
}

// Test we can get all ECS clusters younger than < X time based on tags
func TestCanListAllEcsClustersOlderThan24hours(t *testing.T) {
// create 3 clusters with tags: 1hr, 22hrs, 28hrs
// get all ecs clusters
// get tags for each cluster
// select only clusters older than 24hrs
// assert return only 1 cluster
}

// Test we can nuke all ECS clusters younger than < X time
func TestCanNukeAllEcsClustersOlderThan24Hours(t *testing.T) {
// create 3 clusters with tags: 1hr, 25hrs, 28hrs
// get all ecs clusters
// get tags for each cluster
// select only clusters older than 24hrs
// nuke selected clusters
// assert 2 clusters nuked
// assert 1 cluster still left
}

// Test that we can filter ECS clusters by 'created_at' tag value.
func TestCanCreateWithTagAndFilterEcsClustersByTag(t *testing.T) {
Expand Down Expand Up @@ -86,21 +122,3 @@ func TestCanCreateWithTagAndFilterEcsClustersByTag(t *testing.T) {
// filter results - possibly using api
// assert that result contains your new cluster only (provided it's the only one created in the short time frame)
}

// Test that we can delete ECS clusters by manually creating an ECS cluster, and then deleting it using the nuke function.
func TestNukeEcsClusters(t *testing.T) {
// create ECS cluster
// list all ECS clusters
// nuke all ECS clusters
// list all ECS clusters
// assert no ECS clusters left
}

// Test that we can delete tagged ECS clusters by manually creating an ECS cluster, and then deleting it using the nuke function.
func TestNukeEcsClustersByTag(t *testing.T) {
// create ECS cluster with a 'created_at' tag
// list all ECS clusters with this tag & filter
// nuke ECS cluster by tag and filter
// list all ECS clusters
// assert no ECS clusters as filter criteria
}

0 comments on commit 4faa24e

Please sign in to comment.