@@ -713,6 +713,66 @@ task_definition:
713
713
}
714
714
}
715
715
716
+ func TestReadECSParams_WithServiceDiscoveryAllFields (t * testing.T ) {
717
+ ecsParamsString := `version: 1
718
+ run_params:
719
+ service_discovery:
720
+ container_name: nginx
721
+ container_port: 80
722
+ private_dns_namespace:
723
+ vpc: vpc-8BAADF00D
724
+ id: ns-CA15CA15CA15CA15
725
+ name: corp
726
+ description: This is a private namespace
727
+ public_dns_namespace:
728
+ id: ns-C0VF3F3
729
+ name: amazon.com
730
+ service_discovery_service:
731
+ name: mysds
732
+ description: This is an SDS
733
+ dns_config:
734
+ type: A
735
+ ttl: 60
736
+ routing_policy: MULTIVALUE
737
+ healthcheck_custom_config:
738
+ failure_threshold: 1`
739
+
740
+ content := []byte (ecsParamsString )
741
+
742
+ tmpfile , err := ioutil .TempFile ("" , "ecs-params" )
743
+ assert .NoError (t , err , "Could not create ecs-params tempfile" )
744
+
745
+ ecsParamsFileName := tmpfile .Name ()
746
+ defer os .Remove (ecsParamsFileName )
747
+
748
+ _ , err = tmpfile .Write (content )
749
+ assert .NoError (t , err , "Could not write data to ecs-params tempfile" )
750
+
751
+ err = tmpfile .Close ()
752
+ assert .NoError (t , err , "Could not close tempfile" )
753
+
754
+ ecsParams , err := ReadECSParams (ecsParamsFileName )
755
+
756
+ if assert .NoError (t , err ) {
757
+ serviceDiscovery := ecsParams .RunParams .ServiceDiscovery
758
+ assert .Equal (t , "nginx" , serviceDiscovery .ContainerName , "Expected ContainerName to match" )
759
+ assert .Equal (t , aws .Int64 (80 ), serviceDiscovery .ContainerPort , "Expected ContainerPort to match" )
760
+ assert .Equal (t , "vpc-8BAADF00D" , serviceDiscovery .PrivateDNSNamespace .VPC , "Expected VPC to match" )
761
+ assert .Equal (t , "ns-CA15CA15CA15CA15" , serviceDiscovery .PrivateDNSNamespace .ID , "Expected private namespace ID to match" )
762
+ assert .Equal (t , "corp" , serviceDiscovery .PrivateDNSNamespace .Name , "Expected private namespace Name to match" )
763
+ assert .Equal (t , "This is a private namespace" , serviceDiscovery .PrivateDNSNamespace .Description , "Expected private namespace description to match" )
764
+ assert .Equal (t , "ns-C0VF3F3" , serviceDiscovery .PublicDNSNamespace .ID , "Expected public namespace ID to match" )
765
+ assert .Equal (t , "amazon.com" , serviceDiscovery .PublicDNSNamespace .Name , "Expected public namespace name to match" )
766
+ sds := serviceDiscovery .ServiceDiscoveryService
767
+ assert .Equal (t , "mysds" , sds .Name , "Expected SDS Name to match" )
768
+ assert .Equal (t , "This is an SDS" , sds .Description , "Expected SDS Description to match" )
769
+ assert .Equal (t , "A" , sds .DNSConfig .Type , "Expected SDS DNSConfig Type to match" )
770
+ assert .Equal (t , aws .Int64 (60 ), sds .DNSConfig .TTL , "Expected SDS DNSConfig TTL to match" )
771
+ assert .Equal (t , "MULTIVALUE" , sds .RoutingPolicy , "Expected SDS RoutingPolicy to match" )
772
+ assert .Equal (t , aws .Int64 (1 ), sds .HealthCheckCustomConfig .FailureThreshold , "Expected SDS HealthCheckCustomConfig FailureThreshold to match" )
773
+ }
774
+ }
775
+
716
776
func TestConvertToECSHealthCheck (t * testing.T ) {
717
777
testHealthCheck := & HealthCheck {
718
778
Test : []string {"CMD-SHELL" , "curl -f http://localhost" },
0 commit comments