Skip to content

Commit

Permalink
cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
fredjoonpark committed Jan 3, 2025
1 parent 0ebc36b commit 2b7da78
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions correctness/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ aws timestream-write create-database --database-name CorrectnessDB --region us-w

2. Bring up the Prometheus Connector:
```
`docker compose -f ../docker-compose.yml up -d`
docker compose -f ../docker-compose.yml up -d
```

3. Run `go test -v`. Tests can take between 15~20 seconds to complete.

### Tips

- To run correctness tests against an existing Timestream database, ensure the `freshTSDB` flag is disabled in the test suite.
- The `ingestionWaitTime` parameter is adjustable to account for network latency, ensuring data ingestion is complete before evaluating test outputs.
- The `ingestionWaitTime` parameter is adjustable to account for network latency, ensuring data ingestion is complete before evaluating test outputs. The default of 1 second should be sufficient (and functionally expected), but can increase as needed.

## Clean up
1. Delete your Timestream database:
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
volumes:
- .:/home
command:
- --default-database=CorrDB
- --default-table=CorrMetrics
- --region=us-west-2
- --default-database=PrometheusDatabase
- --default-table=PrometheusMetricsTable
- --region=us-east-1
- --log.level=debug
4 changes: 1 addition & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ func handleWriteRequest(reqBuf []byte, timestreamClient *timestream.Client, awsC

timestream.LogInfo(logger, fmt.Sprintf("Timestream write connection is initialized (Database: %s, Table: %s, Region: %s)", cfg.defaultDatabase, cfg.defaultTable, cfg.clientConfig.region))
if err := getWriteClient(timestreamClient).Write(context.Background(), &writeRequest, credentialsProvider); err != nil {
fmt.Println("A - 1")
errorCode := http.StatusBadRequest
return events.APIGatewayProxyResponse{
StatusCode: errorCode,
Expand Down Expand Up @@ -523,7 +522,7 @@ func createWriteHandler(logger log.Logger, writers []writer) func(w http.Respons
if err := writers[0].Write(context.Background(), &req, awsCredentials); err != nil {
switch err := err.(type) {
case *smithyhttp.ResponseError:
http.Error(w, err.Error(), http.StatusBadRequest)
http.Error(w, err.Error(), http.StatusBadRequest)
case *wtypes.RejectedRecordsException:
http.Error(w, err.Error(), http.StatusUnprocessableEntity)
case *smithy.OperationError:
Expand Down Expand Up @@ -614,7 +613,6 @@ func createReadHandler(logger log.Logger, readers []reader) func(w http.Response
w.Header().Set("Content-Encoding", "snappy")

if _, err := w.Write(snappy.Encode(nil, data)); err != nil {
fmt.Println("C - 1")
timestream.LogError(logger, "Error occurred while writing the encoded ReadResponse to the connection as part of an HTTP reply.", err)
http.Error(w, err.Error(), http.StatusBadRequest)
return
Expand Down
1 change: 1 addition & 0 deletions timestream/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ func (qc *QueryClient) Read(
}, nil
}

// handleSDKErr parses and logs the error from SDK (if any)
func (wc *WriteClient) handleSDKErr(req *prompb.WriteRequest, currErr error, errToReturn error) error {
var responseError *http.ResponseError
if !goErrors.As(currErr, &responseError) {
Expand Down

0 comments on commit 2b7da78

Please sign in to comment.