Skip to content

Commit

Permalink
working api-test flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew7234 committed Apr 3, 2023
1 parent f2653a4 commit d0a5c97
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export HOST_UID := $(shell id -u)
export HOST_GID := $(shell id -g)

all: build

build:
@$(ECHO) "$(CYAN)*** Building...$(OFF)"
@$(MAKE) oasis-indexer
Expand Down Expand Up @@ -58,11 +58,13 @@ test-e2e: export OASIS_INDEXER_E2E = true
test-e2e:
@$(GO) test -race -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic -v ./tests/e2e

dump-state: export OASIS_INDEXER_DUMP_NODE_DATA=true
dump-state:
@OASIS_INDEXER_DUMP_NODE_DATA=true && $(GO) test -race -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic -v ./tests/api
@$(GO) test -race -v ./tests/api

test-api: export OASIS_INDEXER_API_TESTS=true
test-api:
@OASIS_INDEXER_API_TESTS=true && $(GO) test -race -coverpkg=./... -coverprofile=coverage.txt -covermode=atomic -v ./tests/api
@$(GO) test -race -v ./tests/api
./tests/e2e_regression/run.sh

# Format code.
Expand Down
1 change: 1 addition & 0 deletions tests/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestRunFileBasedIndexer(t *testing.T) {
require.Nil(t, err)

consensusAnalyzer, err := consensus.NewMain(cfg.Analysis.Node, cfg.Analysis.Analyzers.Consensus, target, logger)
require.Nil(t, err)

// Initialize file-based source storage.
// TODO: rip this out once the config changes go in
Expand Down
Binary file modified tests/api/data/consensus/00000-1.psg
Binary file not shown.
Binary file modified tests/api/data/consensus/main.pix
Binary file not shown.
Binary file modified tests/api/data/consensus/overflow.pix
Binary file not shown.
1 change: 1 addition & 0 deletions tests/api/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func TestDumpConsensusNodeData(t *testing.T) {

// Initialize consensus analyzer.
consensusAnalyzer, err := consensus.NewMain(cfg.Analysis.Node, cfg.Analysis.Analyzers.Consensus, target, logger)
require.Nil(t, err)

// Initialize file-based source storage.
// TODO: rip this out once the config changes go in
Expand Down
7 changes: 4 additions & 3 deletions tests/e2e_regression/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,19 @@ testCases=(
nCases=${#testCases[@]}

# Kill background processes on exit. (In our case the indexer API server.)
# todo: this doesn't work on MacOS.
trap 'trap - SIGTERM && kill -- -$$' SIGINT SIGTERM EXIT

# Start the API server.
make oasis-indexer
./oasis-indexer --config="${SCRIPT_DIR}/e2e_config.yaml" serve &
./oasis-indexer --config="${SCRIPT_DIR}/../api/api-dev.yml" serve &
while ! curl --silent localhost:8008/v1/ >/dev/null; do
echo "Waiting for API server to start..."
sleep 1
done

# Run the test cases.
seen=()
seen=("placeholder") # avoids 'seen[*]: unbound variable' error on zsh
for (( i=0; i<nCases; i++ )); do
name="$(echo "${testCases[$i]}" | awk '{print $1}')"
url="$(echo "${testCases[$i]}" | awk '{print $2}')"
Expand All @@ -103,7 +104,7 @@ for (( i=0; i<nCases; i++ )); do
>/tmp/pretty 2>/dev/null \
&& cp /tmp/pretty "$outDir/$name.body" || true
# Sanitize the current timestamp out of the response header so that diffs are stable
sed -E -i 's/^(Date|Content-Length|Last-Modified): .*/\1: UNINTERESTING/g' "$outDir/$name.headers"
sed -E -i '' 's/^(Date|Content-Length|Last-Modified): .*/\1: UNINTERESTING/g' "$outDir/$name.headers"
done

diff --recursive "$SCRIPT_DIR/expected" "$outDir" >/dev/null || {
Expand Down

0 comments on commit d0a5c97

Please sign in to comment.