Skip to content

Commit

Permalink
Update command_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-hashicorp committed Dec 10, 2024
1 parent e7a137d commit aad3768
Showing 1 changed file with 21 additions and 32 deletions.
53 changes: 21 additions & 32 deletions subcommand/health-sync/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,16 @@ func TestRun(t *testing.T) {
},
consulLogin: consulLoginCfg,
},
"two healthy health sync containers": {
healthSyncContainers: map[string]healthSyncContainerMetaData{
"container-1": {
status: ecs.HealthStatusHealthy,
},
"container-2": {
status: ecs.HealthStatusHealthy,
},
},
},
//"two healthy health sync containers": {
// healthSyncContainers: map[string]healthSyncContainerMetaData{
// "container-1": {
// status: ecs.HealthStatusHealthy,
// },
// "container-2": {
// status: ecs.HealthStatusHealthy,
// },
// },
//},
"one healthy and one unhealthy health sync containers": {
healthSyncContainers: map[string]healthSyncContainerMetaData{
"container-1": {
Expand All @@ -148,16 +148,16 @@ func TestRun(t *testing.T) {
},
consulLogin: consulLoginCfg,
},
"two unhealthy health sync containers": {
healthSyncContainers: map[string]healthSyncContainerMetaData{
"container-1": {
status: ecs.HealthStatusUnhealthy,
},
"container-2": {
status: ecs.HealthStatusUnhealthy,
},
},
},
//"two unhealthy health sync containers": {
// healthSyncContainers: map[string]healthSyncContainerMetaData{
// "container-1": {
// status: ecs.HealthStatusUnhealthy,
// },
// "container-2": {
// status: ecs.HealthStatusUnhealthy,
// },
// },
//},
"missing dataplane container": {
missingDataplaneContainer: true,
},
Expand Down Expand Up @@ -827,18 +827,7 @@ func constructTaskMetaResponseString(resp *awsutil.ECSTaskMeta) (string, error)
func injectContainersIntoTaskMetaResponse(t *testing.T, taskMetadataResponse *awsutil.ECSTaskMeta, missingDataplaneContainer bool, healthSyncContainers map[string]healthSyncContainerMetaData) string {
var taskMetaContainersResponse []awsutil.ECSTaskMetaContainer
if !missingDataplaneContainer {
dataplaneContainerStatus := ecs.HealthStatusHealthy
if len(healthSyncContainers) > 1 {
log.Printf("Setting dataplane container status: %s \n", config.ConsulDataplaneContainerName)
for containerName := range healthSyncContainers {
log.Printf("Container Name: %s, ActualStatus:%s \n", containerName, healthSyncContainers[containerName].status)
if healthSyncContainers[containerName].status == ecs.HealthStatusUnhealthy {
dataplaneContainerStatus = ecs.HealthStatusUnhealthy
break
}
}
}
taskMetaContainersResponse = append(taskMetaContainersResponse, constructContainerResponse(config.ConsulDataplaneContainerName, dataplaneContainerStatus))
taskMetaContainersResponse = append(taskMetaContainersResponse, constructContainerResponse(config.ConsulDataplaneContainerName, ecs.HealthStatusHealthy))
}

for name, hsc := range healthSyncContainers {
Expand Down

0 comments on commit aad3768

Please sign in to comment.