File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed
internal/testrunner/runners/system/servicedeployer Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -20,10 +20,12 @@ trap cleanup EXIT INT TERM
2020
2121terraform init
2222terraform plan
23- terraform apply -auto-approve && touch /tmp/tf-applied
23+ terraform apply -auto-approve
2424
2525terraform output -json > /output/tfOutputValues.json
2626
27+ touch /tmp/tf-applied # This file is used as indicator (healthcheck) that the service is UP, and so it must be placed as the last statement in the script
28+
2729echo " Terraform definitions applied."
2830
2931set +x
Original file line number Diff line number Diff line change @@ -62,16 +62,10 @@ func addTerraformOutputs(outCtxt ServiceContext) error {
6262 }
6363
6464 // Unmarshall the data into `terraformOutputs`
65- logger .Debug ("Unmarshalling terraform output json " )
65+ logger .Debug ("Unmarshalling terraform output JSON " )
6666 var terraformOutputs map [string ]OutputMeta
67-
68- if ! json .Valid (content ) {
69- logger .Debug ("Invalid Json content in the terraform output file, skipped creating outputs" )
70- return nil
71- }
72-
7367 if err = json .Unmarshal (content , & terraformOutputs ); err != nil {
74- return fmt .Errorf ("error during json Unmarshal %w" , err )
68+ return fmt .Errorf ("error during JSON Unmarshal: %w" , err )
7569 }
7670
7771 if len (terraformOutputs ) == 0 {
@@ -166,7 +160,7 @@ func (tsd TerraformServiceDeployer) SetUp(inCtxt ServiceContext) (DeployedServic
166160
167161 err = addTerraformOutputs (outCtxt )
168162 if err != nil {
169- return nil , fmt .Errorf ("could not handle terraform output %w" , err )
163+ return nil , fmt .Errorf ("could not handle terraform output: %w" , err )
170164 }
171165 service .ctxt = outCtxt
172166 return & service , nil
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ func TestAddTerraformOutputs(t *testing.T) {
2020 runId string
2121 content []byte
2222 expectedProps map [string ]interface {}
23+ expectedError bool
2324 }{
2425 {
2526 testName : "invalid_json_output" ,
@@ -31,6 +32,7 @@ func TestAddTerraformOutputs(t *testing.T) {
3132 `` ,
3233 ),
3334 expectedProps : map [string ]interface {}{},
35+ expectedError : true ,
3436 },
3537 {
3638 testName : "empty_json_output" ,
@@ -145,6 +147,10 @@ func TestAddTerraformOutputs(t *testing.T) {
145147
146148 // Test that the terraform output values are generated correctly
147149 err := addTerraformOutputs (tc .ctxt )
150+ if tc .expectedError {
151+ require .Error (t , err )
152+ return
153+ }
148154 require .NoError (t , err )
149155 assert .Equal (t , tc .expectedProps , tc .ctxt .CustomProperties )
150156 })
You can’t perform that action at this time.
0 commit comments