diff --git a/scripts/docker-integration-tests/prometheus/test.sh b/scripts/docker-integration-tests/prometheus/test.sh index fe13f761b7..518165e3ff 100755 --- a/scripts/docker-integration-tests/prometheus/test.sh +++ b/scripts/docker-integration-tests/prometheus/test.sh @@ -11,6 +11,13 @@ echo "Run m3dbnode and m3coordinator containers" docker-compose -f ${COMPOSE_FILE} up -d dbnode01 docker-compose -f ${COMPOSE_FILE} up -d coordinator01 +# think of this as a defer func() in golang +function defer { + docker-compose -f ${COMPOSE_FILE} down || echo "unable to shutdown containers" # CI fails to stop all containers sometimes +} +trap defer EXIT + + echo "Sleeping for a bit to ensure db up" sleep 15 # TODO Replace sleeps with logic to determine when to proceed @@ -104,4 +111,13 @@ echo "Wait until the remote write endpoint generates and allows for data to be q ATTEMPTS=6 TIMEOUT=2 retry_with_backoff \ '[[ $(curl -sSf 0.0.0.0:9090/api/v1/query?query=prometheus_remote_storage_succeeded_samples_total | jq -r .data.result[].value[1]) -gt 100 ]]' -docker-compose -f ${COMPOSE_FILE} down || echo "unable to shutdown containers" # CI fails to stop all containers sometimes +# Make sure we're proxying writes to the unaggregated namespace +echo "Wait until data begins being written to remote storage for the unaggregated namespace" +ATTEMPTS=6 TIMEOUT=2 retry_with_backoff \ + '[[ $(curl -sSf 0.0.0.0:9090/api/v1/query?query=database_write_tagged_success\\{namespace=\"unagg\"\\} | jq -r .data.result[0].value[1]) -gt 0 ]]' + +# Make sure we're proxying writes to the aggregated namespace +echo "Wait until data begins being written to remote storage for the aggregated namespace" +ATTEMPTS=10 TIMEOUT=2 retry_with_backoff \ + '[[ $(curl -sSf 0.0.0.0:9090/api/v1/query?query=database_write_tagged_success\\{namespace=\"agg\"\\} | jq -r .data.result[0].value[1]) -gt 0 ]]' + diff --git a/scripts/docker-integration-tests/simple/test.sh b/scripts/docker-integration-tests/simple/test.sh index 8c054b13db..47a6671a89 100755 --- a/scripts/docker-integration-tests/simple/test.sh +++ b/scripts/docker-integration-tests/simple/test.sh @@ -9,6 +9,14 @@ echo "Run m3dbnode docker container" CONTAINER_NAME="m3dbnode-version-${REVISION}" docker create --name "${CONTAINER_NAME}" -p 9000:9000 -p 9001:9001 -p 9002:9002 -p 9003:9003 -p 9004:9004 -p 7201:7201 "m3dbnode_integration:${REVISION}" + +# think of this as a defer func() in golang +function defer { + echo "Remove docker container" + docker rm --force "${CONTAINER_NAME}" +} +trap defer EXIT + docker start "${CONTAINER_NAME}" if [ $? -ne 0 ]; then echo "m3dbnode docker failed to start" @@ -118,9 +126,3 @@ curl -vvvsSf -X DELETE 0.0.0.0:7201/api/v1/placement echo "Deleting namespace" curl -vvvsSf -X DELETE 0.0.0.0:7201/api/v1/namespace/default - -echo "Stop docker container" -docker stop "${CONTAINER_NAME}" - -echo "Remove docker container" -docker rm "${CONTAINER_NAME}" \ No newline at end of file diff --git a/src/query/api/v1/httpd/handler.go b/src/query/api/v1/httpd/handler.go index 302a951641..e0d9ce5575 100644 --- a/src/query/api/v1/httpd/handler.go +++ b/src/query/api/v1/httpd/handler.go @@ -103,7 +103,7 @@ func (h *Handler) RegisterRoutes() error { // Prometheus remote read/write endpoints promRemoteReadHandler := remote.NewPromReadHandler(h.engine, h.scope.Tagged(remoteSource)) - promRemoteWriteHandler, err := remote.NewPromWriteHandler(h.storage, nil, h.scope.Tagged(remoteSource)) + promRemoteWriteHandler, err := remote.NewPromWriteHandler(h.storage, h.downsampler, h.scope.Tagged(remoteSource)) if err != nil { return err } diff --git a/src/query/server/server.go b/src/query/server/server.go index f74f517ae0..7a43a2d0d2 100644 --- a/src/query/server/server.go +++ b/src/query/server/server.go @@ -60,6 +60,7 @@ import ( xtime "github.com/m3db/m3x/time" "github.com/pkg/errors" + "github.com/uber-go/tally" "go.uber.org/zap" "google.golang.org/grpc" ) @@ -355,11 +356,12 @@ func newDownsampler( SubScope("tag-decoder-pool"))) downsampler, err := downsample.NewDownsampler(downsample.DownsamplerOptions{ - Storage: storage, - RulesKVStore: kvStore, - AutoMappingRules: autoMappingRules, - ClockOptions: clock.NewOptions(), - InstrumentOptions: instrumentOpts, + Storage: storage, + RulesKVStore: kvStore, + AutoMappingRules: autoMappingRules, + ClockOptions: clock.NewOptions(), + // TODO: remove after https://github.com/m3db/m3/issues/992 is fixed + InstrumentOptions: instrumentOpts.SetMetricsScope(tally.NoopScope), TagEncoderOptions: tagEncoderOptions, TagDecoderOptions: tagDecoderOptions, TagEncoderPoolOptions: tagEncoderPoolOptions,