diff --git a/mock_server/certificates/private.key b/mock_server/certificates/private.key deleted file mode 100644 index f1b25e528..000000000 --- a/mock_server/certificates/private.key +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQCUVAB1VBcztRsu -D0Kr+OVwEiN5HfinLUwh+SqX1fjPuSgU5ISfzYAy4aQ20H3rpee7y0DjNyDBKnTH -yxHcN/RNoRsM0D96QuRYx9+P5wCUUNchK7Pku/lFsJiO0TtuCxA5JqrlQRx7WHnu -eCiC+vneaL/Nj65EhPC/jiMuMh/VTRGnXa/Cf9XWU8AjYGuuLy6n8ari9s1BbNRM -FxWDJHWrrfCEiYf0bJX1bykABMaW1zE3Ql1ophxdL2qy4cXtEQwG3XswwV7f0tUh -unvpTymH69p0Cicz137vxnt03okwob1hz2DbMOX9YHC2tyNCuLBC05VSlaBuvQeN -sh2YPXq1LdSUF5S3XZa+JotolXcCTQ5oxvrqqjQATPHGQrnkn/tfzMs1S5crvzie -17BBGGAGbMOE6Guj+MuPxzrvvx6ZtXL8jFWlgQTLcLTf+haY7mIez+1VXHjPYEtt -wEweMK+z+qVX2YgEBl4mC5+hfvww57HPx7+6Tf3gqcRRKjeUDGN4XhnbskXyCIsj -6LJCLTAaVULXgcSZc1E65EAGgWxeYTpl8SM7/QAq6jC+FcWTIIcIkg4sPILOlFyj -ZhOuIg+tPhIusUQFEtiHEtddYorJPG0bZnTmeZfjvaAbhERkeIC4mZOyyLB0Oen2 -kR8WXYL3uSmTsoYLnqw6nnw+DecfKQIDAQABAoICAAGReXduxhexnUHe1ES3Cw6k -3nOldboncDPha3TIr3VbdDlI/j77Sv+euPVXEycWmA05VaxhVOsTQhdVBhFm6mIX -ZzllippGEp3UBSuDaiiR9JMA9YlgVGnLIh3LyAipPMjB6Cd9iVR43RcrSuWxoMqG -ydUIT8khLQjKyFlGGzs5MfaBTCkECtSAilpFZstkFnvyQe0y5fzVrqacT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p7Omyz6 -AVyUAyScT9mjLz7faAGEA+e9ThrIfd/N0ohAhKMGnvPMpYvw6c8NP8AGFvFAt2kt -0rI6iVINGaTTRWLvOZOnOrZ6RFXOHg== ------END PRIVATE KEY----- diff --git a/mock_server/certificates/ssl/ca-bundle.crt b/mock_server/certificates/ssl/ca-bundle.crt deleted file mode 100644 index 7af408469..000000000 --- a/mock_server/certificates/ssl/ca-bundle.crt +++ /dev/null @@ -1,36 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIGOTCCBCGgAwIBAgIUcz7fCLPSodq6qjL3Czp30dMvib4wDQYJKoZIhvcNAQEL -BQAwgaAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQH -DAdTZWF0dGxlMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxFjAUBgNVBAsMDUlU -IERlcGFydG1lbnQxIjAgBgkqhkiG9w0BCQEWE2V4YW1wbGVAZXhhbXBsZS5jb20x -FDASBgNVBAMMC2V4YW1wbGUuY29tMB4XDTIzMDgwOTE5MjUzNloXDTI0MDgwODE5 -MjUzNlowgaAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYD -VQQHDAdTZWF0dGxlMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxFjAUBgNVBAsM -DUlUIERlcGFydG1lbnQxIjAgBgkqhkiG9w0BCQEWE2V4YW1wbGVAZXhhbXBsZS5j -b20xFDASBgNVBAMMC2V4YW1wbGUuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A -MIICCgKCAgEAlFQAdVQXM7UbLg9Cq/jlcBIjeR34py1MIfkql9X4z7koFOSEn82A -MuGkNtB966Xnu8tA4zcgwSp0x8sR3Df0TaEbDNA/ekLkWMffj+cAlFDXISuz5Lv5 -RbCYjtE7bgsQOSaq5UEce1h57ngogvr53mi/zY+uRITwv44jLjIf1U0Rp12vwn/V -1lPAI2Brri8up/Gq4vbN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E -G+b0+A8S5VEFzARO4RWwiXAxjhyWfPgC+TYPar5pmD7XGL6J1XepAvZGUsW0mqZD -9MdV62syt1kX2Ogok6Wz4dCkvzzy9N+oY+LvNhQfSr6ahDVZJ3up+oqzjhJr+Xf+ -MSF6scI421mTP7mf3MEQDwISoTAtFOHvuHEHZnJws7pJfmPiiG0WdxclJ25RFya7 -s+nwKPP+rz7AUrqkxc16nZlJLlfNqWRoFsrkNbg5AaLMAKzsdrWRBPkXig1siseD -teHsab59Of+lkNRo2g== ------END CERTIFICATE----- diff --git a/mock_server/certificates/ssl/certificate.crt b/mock_server/certificates/ssl/certificate.crt deleted file mode 100644 index 7af408469..000000000 --- a/mock_server/certificates/ssl/certificate.crt +++ /dev/null @@ -1,36 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIGOTCCBCGgAwIBAgIUcz7fCLPSodq6qjL3Czp30dMvib4wDQYJKoZIhvcNAQEL -BQAwgaAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYDVQQH -DAdTZWF0dGxlMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxFjAUBgNVBAsMDUlU -IERlcGFydG1lbnQxIjAgBgkqhkiG9w0BCQEWE2V4YW1wbGVAZXhhbXBsZS5jb20x -FDASBgNVBAMMC2V4YW1wbGUuY29tMB4XDTIzMDgwOTE5MjUzNloXDTI0MDgwODE5 -MjUzNlowgaAxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9uMRAwDgYD -VQQHDAdTZWF0dGxlMRgwFgYDVQQKDA9FeGFtcGxlIENvbXBhbnkxFjAUBgNVBAsM -DUlUIERlcGFydG1lbnQxIjAgBgkqhkiG9w0BCQEWE2V4YW1wbGVAZXhhbXBsZS5j -b20xFDASBgNVBAMMC2V4YW1wbGUuY29tMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A -MIICCgKCAgEAlFQAdVQXM7UbLg9Cq/jlcBIjeR34py1MIfkql9X4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9kS5ReCdkqqkafM2kqmJeB5nQ/Y -zyc8szw4+sJKf7Fszq6xW9AkzKZRhaNumWXTeTMALoq5/WfA4J4jcQ0BmVLPWA01 -zYCdlNb0HHDKq/1ejWpfb3w/TWncdntqYndYRUR2Mr/1HNPSAiP6vaqFH6e/fzbE -G+b0+A8S5VEFzARO4RWwiXAxjhyWfPgC+TYPar5pmD7XGL6J1XepAvZGUsW0mqZD -9MdV62syt1kX2Ogok6Wz4dCkvzzy9N+oY+LvNhQfSr6ahDVZJ3up+oqzjhJr+Xf+ -MSF6scI421mTP7mf3MEQDwISoTAtFOHvuHEHZnJws7pJfmPiiG0WdxclJ25RFya7 -s+nwKPP+rz7AUrqkxc16nZlJLlfNqWRoFsrkNbg5AaLMAKzsdrWRBPkXig1siseD -teHsab59Of+lkNRo2g== ------END CERTIFICATE----- diff --git a/mock_server/Makefile b/mockserver/Makefile similarity index 100% rename from mock_server/Makefile rename to mockserver/Makefile diff --git a/mock_server/README b/mockserver/README similarity index 56% rename from mock_server/README rename to mockserver/README index 74b5c8444..10cdf5346 100644 --- a/mock_server/README +++ b/mockserver/README @@ -1,8 +1,3 @@ # Mocked Servers -Most of the tests use mocked servers as stand-ins for the exporters to send to. -The docker images are built and pushed to ECR as part of `terraform/imagebuild` and then used in the tests as part of `defaults/docker_compose.tpl`. - -Most will use the `https` mocked_server, but some test cases like `otlp_grpc_exporter_metric_mock` and `otlp_grpc_exporter_trace_mock` will need to use the `grpc_metrics` and `grpc_trace` mocked_servers. - The servers themselves are very basic. They listen for a message and tend to set a flag to success upon receiving it. Typically, they are set up with two servers: one to mock the backend and one to report on the status of that mock (if endpoint is called, how many times, etc.). There's a built-in 15ms of latency between each message that's received. The status reporter will always be on port 8080 and support the `:8080/` (returns "healthcheck") and the `:8080/check-data` (returns "success" if mock has received messages) endpoints. \ No newline at end of file diff --git a/mockserver/certificates/private.key b/mockserver/certificates/private.key new file mode 100644 index 000000000..e69de29bb diff --git a/mockserver/certificates/ssl/ca-bundle.crt b/mockserver/certificates/ssl/ca-bundle.crt new file mode 100644 index 000000000..e69de29bb diff --git a/mockserver/certificates/ssl/certificate.crt b/mockserver/certificates/ssl/certificate.crt new file mode 100644 index 000000000..e69de29bb diff --git a/mock_server/http_server.go b/mockserver/http_server.go similarity index 96% rename from mock_server/http_server.go rename to mockserver/http_server.go index e841d2dc0..cdf60494f 100644 --- a/mock_server/http_server.go +++ b/mockserver/http_server.go @@ -52,11 +52,11 @@ func healthCheck(w http.ResponseWriter, _ *http.Request) { func (ts *transactionStore) checkData(w http.ResponseWriter, _ *http.Request) { var message string - var t =atomic.LoadUint32(&ts.transactions) - if t > 0 { + var t = atomic.LoadUint32(&ts.transactions) + if t > 0 { message = SuccessMessage } - fmt.Printf("\033[31m Time: %d | checkData msg: %s | %d\033[0m \n", time.Now().Unix(), message,t) + fmt.Printf("\033[31m Time: %d | checkData msg: %s | %d\033[0m \n", time.Now().Unix(), message, t) if _, err := io.WriteString(w, message); err != nil { io.WriteString(w, err.Error()) log.Printf("Unable to write response: %v", err) @@ -88,7 +88,7 @@ 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{} { +func StartHttpServer() chan interface{} { serverControlChan := make(chan interface{}) log.Println("\033[31m Starting Server \033[0m") store := transactionStore{startTime: time.Now()} @@ -102,7 +102,7 @@ func startHttpServer() chan interface{} { 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 { + if err := daemonServer.ListenAndServeTLS(CertFilePath, KeyFilePath); err != nil { log.Fatalf("HTTPS server error: %v", err) err = daemonServer.Shutdown(context.TODO()) log.Fatalf("Shutdown server error: %v", err) diff --git a/mock_server/http_server_test.go b/mockserver/http_server_test.go similarity index 87% rename from mock_server/http_server_test.go rename to mockserver/http_server_test.go index b90420765..a4d19fc12 100644 --- a/mock_server/http_server_test.go +++ b/mockserver/http_server_test.go @@ -83,29 +83,16 @@ func HttpServerCheckTPM(t *testing.T) { assert.Truef(t, tpm.(float64) > 1, "tpm is less than 1 %f", tpm) } -// func HttpServerSendData(t *testing.T,) { -// var wg sync.WaitGroup -// wg.Add(2) -// go func(){ -// defer wg.Done() -// for i := 1; i < 5; i++ { -// HttpServerCheckTPM(t) -// time.Sleep(TPM_CHECK_INTERVAL) -// } -// }() -// wg.Wait() -// } func TestMockServer(t *testing.T) { - serverControlChan := startHttpServer() + serverControlChan := StartHttpServer() time.Sleep(3 * time.Second) HttpServerSanityCheck(t, APP_SERVER) HttpsServerSanityCheck(t, DATA_SERVER) - // HttpServerSendData(t) - // time.Sleep(1 * time.Minute) + time.Sleep(5 * time.Minute) serverControlChan <- 0 } func TestStartMockServer(t *testing.T) { - startHttpServer() + StartHttpServer() } diff --git a/mock_server/openssl.conf b/mockserver/openssl.conf similarity index 100% rename from mock_server/openssl.conf rename to mockserver/openssl.conf diff --git a/terraform/performance/main.tf b/terraform/performance/main.tf index 2374c4c8d..a777f6141 100644 --- a/terraform/performance/main.tf +++ b/terraform/performance/main.tf @@ -91,8 +91,6 @@ resource "null_resource" "install_binaries" { "aws s3 cp s3://${var.s3_bucket}/integration-test/packaging/${var.cwa_github_sha}/amazon-cloudwatch-agent.msi .", "aws s3 cp s3://${var.s3_bucket}/integration-test/binary/${var.cwa_github_sha}/${var.family}/${var.arc}/${local.install_package} .", "aws s3 cp s3://${var.s3_bucket}/integration-test/validator/${var.cwa_github_sha}/${var.family}/${var.arc}/${local.install_validator} .", - "git clone https://github.com/okankoAMZ/amazon-cloudwatch-agent-test.git", - "cp -r amazon-cloudwatch-agent-test/test/xray/resources /home/ec2-user/", local.ami_family["install_command"], ] } @@ -113,7 +111,14 @@ resource "null_resource" "validator_linux" { inline = [ "export AWS_REGION=${var.region}", "sudo chmod +x ./${local.install_validator}", + #mock server dependencies getting transfered. + "git clone https://github.com/okankoAMZ/amazon-cloudwatch-agent-test.git", + "cd amazon-cloudwatch-agent-test && git checkout xray-performance-test && cd ..", + "cp -r amazon-cloudwatch-agent-test/test/xray/resources /home/ec2-user/", + "cp -a amazon-cloudwatch-agent-test/mockserver/. /home/ec2-user/", + "make update-certs", "./${local.install_validator} --validator-config=${module.validator.instance_validator_config} --preparation-mode=true", + "sudo setcap 'cap_net_bind_service=+ep' validator", local.start_command, "./${local.install_validator} --validator-config=${module.validator.instance_validator_config} --preparation-mode=false", ] diff --git a/test/performance/trace/xray/agent_config.json b/test/performance/trace/xray/agent_config.json index aedc8d55b..694df9f5a 100644 --- a/test/performance/trace/xray/agent_config.json +++ b/test/performance/trace/xray/agent_config.json @@ -8,100 +8,5 @@ "xray": { } } - }, - "metrics": { - "namespace": "CloudWatchAgentPerformance", - "append_dimensions": { - "InstanceId": "${aws:InstanceId}" - }, - "metrics_collected": { - "cpu": { - "measurement": [ - "time_active", "time_guest", "time_guest_nice", "time_idle", "time_iowait", "time_irq", - "time_nice", "time_softirq", "time_steal", "time_system", "time_user", - "usage_active", "usage_guest", "usage_guest_nice", "usage_idle", "usage_iowait", "usage_irq", - "usage_nice", "usage_softirq", "usage_steal", "usage_system", "usage_user" - ], - "metrics_collection_interval": 1 - }, - "swap": { - "measurement": [ - "free","used","used_percent" - ], - "metrics_collection_interval": 1 - }, - "processes": { - "measurement": [ - "blocked","running","sleeping","stopped","total","dead","idle","paging","total_threads","zombies" - ], - "metrics_collection_interval": 1 - }, - "netstat": { - "measurement": [ - "tcp_close","tcp_close_wait","tcp_closing", "tcp_established","tcp_fin_wait1","tcp_fin_wait2","tcp_last_ack", - "tcp_listen","tcp_none","tcp_syn_sent","tcp_syn_recv","tcp_time_wait","udp_socket" - ], - "metrics_collection_interval": 1 - }, - "mem": { - "measurement": [ - "active", "available", "available_percent", "buffered", "cached", "free", "inactive", "total", - "used", "used_percent" - ], - "metrics_collection_interval": 1 - }, - "diskio": { - "resources": [ - "*" - ], - "measurement": [ - "iops_in_progress", "io_time", "reads", "read_bytes", "read_time", "writes", "write_bytes", "write_time" - ], - "metrics_collection_interval": 1 - }, - "disk": { - "resources": [ - "*" - ], - "measurement": [ - "free","inodes_free","inodes_total","inodes_used","total","used","used_percent" - ], - "drop_device": true, - "metrics_collection_interval": 1 - }, - "ethtool": { - "interface_include": [ - "eth0", - "ens5" - ], - "metrics_include": [ - "queue_0_tx_cnt","queue_0_rx_cnt" - ] - }, - "net": { - "resources": [ - "eth0" - ], - "measurement": [ - "bytes_sent", "bytes_recv", "drop_in", "drop_out", "err_in", "err_out", "packets_sent", "packets_recv" - ], - "metrics_collection_interval": 1 - }, - "procstat": [ - { - "exe": "cloudwatch-agent", - "measurement": [ - "cpu_usage", - "memory_rss", - "memory_swap", - "memory_vms", - "memory_data", - "num_fds", - "write_bytes" - ], - "metrics_collection_interval": 1 - } - ] } - } } \ No newline at end of file diff --git a/util/common/traces.go b/util/common/traces.go index e194d1b4c..7682f3569 100644 --- a/util/common/traces.go +++ b/util/common/traces.go @@ -3,6 +3,7 @@ package common import ( "context" "encoding/json" + "log" "reflect" "testing" "time" @@ -112,13 +113,14 @@ func SegmentValidationTest(t *testing.T, traceTest TraceTestConfig, segments []t return nil } -func GenerateTraces(traceTest TraceTestConfig) error{ - CopyFile(traceTest.AgentConfigPath, ConfigOutputPath) - go func() { - traceTest.Generator.StartSendingTraces(context.Background()) - }() - time.Sleep(traceTest.AgentRuntime) - traceTest.Generator.StopSendingTraces() - time.Sleep(AGENT_SHUTDOWN_DELAY) - return nil +func GenerateTraces(traceTest TraceTestConfig) error { + CopyFile(traceTest.AgentConfigPath, ConfigOutputPath) + go func() { + err := traceTest.Generator.StartSendingTraces(context.Background()) + log.Printf("Error sending traces: %v", err) + }() + time.Sleep(traceTest.AgentRuntime) + traceTest.Generator.StopSendingTraces() + time.Sleep(AGENT_SHUTDOWN_DELAY) + return nil } diff --git a/validator/resources/sampling-rule.json b/validator/resources/sampling-rule.json deleted file mode 100644 index 72d46496e..000000000 --- a/validator/resources/sampling-rule.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": 2, - "rules": [ - { - "description": "debug", - "host": "*", - "http_method": "*", - "url_path": "*", - "fixed_target": 0, - "rate": 1.0 - } - ], - "default": { - "fixed_target": 1, - "rate": 1.0 - } - } \ No newline at end of file diff --git a/validator/resources/xray-config.json b/validator/resources/xray-config.json deleted file mode 100644 index 75be23507..000000000 --- a/validator/resources/xray-config.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "agent":{ - "debug":true - }, - "traces": { - "traces_collected": { - "xray": { - } - } - } -} \ No newline at end of file diff --git a/validator/validators/basic/resources/sampling-rule.json b/validator/validators/basic/resources/sampling-rule.json deleted file mode 100644 index 72d46496e..000000000 --- a/validator/validators/basic/resources/sampling-rule.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": 2, - "rules": [ - { - "description": "debug", - "host": "*", - "http_method": "*", - "url_path": "*", - "fixed_target": 0, - "rate": 1.0 - } - ], - "default": { - "fixed_target": 1, - "rate": 1.0 - } - } \ No newline at end of file diff --git a/validator/validators/util/common.go b/validator/validators/util/common.go index 7fc272031..48736edf7 100644 --- a/validator/validators/util/common.go +++ b/validator/validators/util/common.go @@ -6,7 +6,6 @@ package util import ( "fmt" "time" - "github.com/aws/amazon-cloudwatch-agent-test/test/xray" "github.com/aws/amazon-cloudwatch-agent-test/util/common" "github.com/aws/aws-sdk-go-v2/service/cloudwatch/types" @@ -22,17 +21,17 @@ func LogCloudWatchDimension(dims []types.Dimension) string { return dimension } -func StartTraceGeneration(receiver string, agentConfigPath string,agentRuntime time.Duration ,traceSendingInterval time.Duration) error{ +func StartTraceGeneration(receiver string, agentConfigPath string, agentRuntime time.Duration, traceSendingInterval time.Duration) error { cfg := common.TraceTestConfig{ - Generator: nil, - Name: "", - AgentConfigPath: agentConfigPath, - AgentRuntime: agentRuntime, + Generator: nil, + Name: "", + AgentConfigPath: agentConfigPath, + AgentRuntime: agentRuntime, } xrayGenCfg := common.TraceGeneratorConfig{ Interval: traceSendingInterval, - Annotations:map[string]interface{}{ - "test_type": "simple_otlp", + Annotations: map[string]interface{}{ + "test_type": "simple_otlp", }, Metadata: map[string]map[string]interface{}{ "default": { @@ -44,14 +43,15 @@ func StartTraceGeneration(receiver string, agentConfigPath string,agentRuntime t "custom_key": "custom_value", }, }, - } - switch receiver{ + } + switch receiver { case "xray": cfg.Generator = xray.NewLoadGenerator(&xrayGenCfg) cfg.Name = "xray-performance-test" case "otlp": + panic("Only supports xray for now.") default: - panic("Invalid trace receiver") + panic("Invalid trace receiver") } err := common.GenerateTraces(cfg) return err diff --git a/validator/validators/validator.go b/validator/validators/validator.go index f8da17d36..0c2f881db 100644 --- a/validator/validators/validator.go +++ b/validator/validators/validator.go @@ -8,6 +8,7 @@ import ( "log" "time" + "github.com/aws/amazon-cloudwatch-agent-test/mockserver" "github.com/aws/amazon-cloudwatch-agent-test/validator/models" "github.com/aws/amazon-cloudwatch-agent-test/validator/validators/feature" "github.com/aws/amazon-cloudwatch-agent-test/validator/validators/performance" @@ -44,7 +45,8 @@ func LaunchValidator(vConfig models.ValidateConfig) error { log.Printf("Start to sleep %f s for the metric to be available in the beginning of next minute ", durationBeforeNextMinute.Seconds()) time.Sleep(durationBeforeNextMinute) - + log.Printf("Start mock server \n") + mockserverChan := mockserver.StartHttpServer() log.Printf("Start to generate load in %f s for the agent to collect and send all the metrics to CloudWatch within the datapoint period ", agentCollectionPeriod.Seconds()) err = validator.GenerateLoad() if err != nil { @@ -60,7 +62,9 @@ func LaunchValidator(vConfig models.ValidateConfig) error { if err != nil { return err } - + log.Printf("Closing the mock server") + mockserverChan <- 0 + close(mockserverChan) err = validator.Cleanup() if err != nil { return err