diff --git a/generator/test_case_generator.go b/generator/test_case_generator.go index 49adb820e..44daec2e1 100644 --- a/generator/test_case_generator.go +++ b/generator/test_case_generator.go @@ -31,7 +31,6 @@ type matrixRow struct { TerraformDir string `json:"terraform_dir"` UseSSM bool `json:"useSSM"` ExcludedTests string `json:"excludedTests"` - RunMockServer bool `json:"run_mock_server"` MetadataEnabled string `json:"metadataEnabled"` } @@ -123,8 +122,7 @@ var testTypeToTestConfig = map[string][]testConfig{ {testDir: "../../test/performance/system"}, {testDir: "../../test/performance/statsd"}, {testDir: "../../test/performance/collectd"}, - {testDir: "../../test/performance/trace/xray", - runMockServer: true}, + {testDir: "../../test/performance/trace/xray",runMockServer: true}, }, "ec2_windows_performance": { {testDir: "../../test/performance/windows/logs"}, @@ -227,8 +225,7 @@ func genMatrix(testType string, testConfigs []testConfig) []matrixRow { testMatrixComplete := make([]matrixRow, 0, len(testMatrix)) for _, test := range testMatrix { for _, testConfig := range testConfigs { - row := matrixRow{TestDir: testConfig.testDir, TestType: testType, TerraformDir: testConfig.terraformDir, - RunMockServer: testConfig.runMockServer} + row := matrixRow{TestDir: testConfig.testDir, TestType: testType, TerraformDir: testConfig.terraformDir} err = mapstructure.Decode(test, &row) if err != nil { log.Panicf("can't decode map test %v to metric line struct with error %v", testConfig, err) diff --git a/mockserver/main.go b/mockserver/main.go index 8e502a3b2..a087b7c21 100644 --- a/mockserver/main.go +++ b/mockserver/main.go @@ -22,6 +22,7 @@ import ( "log" "net/http" "path" + "sync" "sync/atomic" "time" @@ -47,7 +48,7 @@ type TransactionPayload struct { TransactionsPerMinute float64 `json:"tpm"` } -func healthCheck(w http.ResponseWriter, _ *http.Request) { +func healthCheck(w http.ResponseWriter, _ *http.Request) { if _, err := io.WriteString(w, HealthCheckMessage); err != nil { log.Printf("Unable to write response: %v", err) } @@ -91,8 +92,8 @@ func (ts *transactionStore) tpm(w http.ResponseWriter, _ *http.Request) { // Starts an HTTPS server that receives requests for the data handler service at the sample server port // Starts an HTTP server that receives request from validator only to verify the data ingestion -func StartHttpServer() chan interface{} { - serverControlChan := make(chan interface{}) +func StartHttpServer() { + var wg sync.WaitGroup log.Println("\033[31m Starting Server \033[0m") store := transactionStore{startTime: time.Now()} dataApp := mux.NewRouter() @@ -100,47 +101,33 @@ func StartHttpServer() chan interface{} { verifyApp := http.NewServeMux() appServer := &http.Server{Addr: ":8080", Handler: verifyApp} go func(ts *transactionStore) { - defer close(serverControlChan) - dataApp.HandleFunc("/", healthCheck) + wg.Add(1) + dataApp.HandleFunc("/ping", healthCheck) dataApp.PathPrefix("/put-data").HandlerFunc(ts.dataReceived) dataApp.HandleFunc("/trace/v1", ts.dataReceived) dataApp.HandleFunc("/metric/v1", ts.dataReceived) if err := daemonServer.ListenAndServeTLS(CertFilePath, KeyFilePath); err != nil { - log.Fatalf("HTTPS server error: %v", err) + log.Printf("HTTPS server error: %v", err) err = daemonServer.Shutdown(context.TODO()) log.Fatalf("Shutdown server error: %v", err) } }(&store) go func(ts *transactionStore) { - defer close(serverControlChan) - verifyApp.HandleFunc("/", healthCheck) + wg.Add(1) + verifyApp.HandleFunc("/ping", healthCheck) verifyApp.HandleFunc("/check-data", ts.checkData) verifyApp.HandleFunc("/tpm", ts.tpm) if err := appServer.ListenAndServe(); err != nil { - log.Fatalf("Verification server error: %v", err) + log.Printf("Verification server error: %v", err) err := appServer.Shutdown(context.TODO()) log.Fatalf("Shuwdown server error: %v", err) } }(&store) - go func() { - for { - select { - case <-serverControlChan: - log.Println("\033[32m Stopping Server \033[0m") - - } - } - }() - - return serverControlChan + wg.Done() + log.Println("\033[32m Stopping Server \033[0m") } func main() { - server := StartHttpServer() - select { - case <-server: - fmt.Println("server is dead") - - } + StartHttpServer() }