Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example tester service to show API Integration Testing of a Goa System #331

Merged
merged 52 commits into from
Jan 6, 2024

Conversation

jasondborneman
Copy link
Contributor

@jasondborneman jasondborneman commented Nov 21, 2023

  • upgrade from goa v3.11.0 -> goa 3.14.0
    • This caused a number of files to be updated mostly with change for the // Code generated by comment + changing interface{} to any
  • New tester service
  • New calls in front that wrap the tester service's TestAll and TestSmoke methods
  • New github action workflow that runs tester smoke tests via front service.

@jasondborneman jasondborneman marked this pull request as draft November 21, 2023 19:23
Copy link
Member

@raphael raphael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome!! Left a bunch of nitpicks and comments

example/weather/services/front/clients/tester/client.go Outdated Show resolved Hide resolved
example/weather/services/front/clients/tester/client.go Outdated Show resolved Hide resolved
example/weather/services/front/design/design.go Outdated Show resolved Hide resolved
example/weather/services/tester/run_tests.go Outdated Show resolved Hide resolved
example/weather/services/tester/run_tests.go Outdated Show resolved Hide resolved
example/weather/services/tester/run_tests.go Show resolved Hide resolved
example/weather/services/tester/run_tests.go Show resolved Hide resolved
example/weather/services/tester/testing.go Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Nov 28, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0097ea4) 94.30% compared to head (78ca536) 94.30%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #331   +/-   ##
=======================================
  Coverage   94.30%   94.30%           
=======================================
  Files          40       40           
  Lines        2249     2249           
=======================================
  Hits         2121     2121           
  Misses         95       95           
  Partials       33       33           
Flag Coverage Δ
micro 94.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@raphael raphael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, added a nit

./bin/locator -monitoring-enabled=false &
./bin/tester -monitoring-enabled=false &
./bin/front -monitoring-enabled=false &
sleep 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we couldn't instead wait for the service health checks to start responding? Using sleep really isn't great... Maybe we could introduct a function such as:

check_service_health() {
    local health_url="$1"
    local start_time=$(date +%s)

    while : ; do
        if curl -s --fail "$health_url" > /dev/null; then
            echo "Service is up!"
            return 0
        fi

        local current_time=$(date +%s)
        if (( current_time - start_time >= 5 )); then
            echo "Timed out waiting for service to be up."
            return 1
        fi

        sleep 0.2
    done
}

and then call it for each service concurrently and wait for the calls to return:

check_service_health "http://localhost:????/healthz" &
check_service_health "http://localhost:????/healthz" &
check_service_health "http://localhost:????/healthz" &
check_service_health "http://localhost:????/healthz" &
wait

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to tweak it a bit and add -n to the wait (otherwise it just hung) but this was a great suggestion, thanks!

@@ -9,10 +9,21 @@ source ./scripts/utils/common.sh

proto_pkg="protobuf-compiler"

# install protoc, update version as needed
PROTO_VER=24.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest version is 25.1 - it's a race! :)

@jasondborneman jasondborneman marked this pull request as ready for review January 5, 2024 14:09
@raphael raphael merged commit 15fc752 into goadesign:main Jan 6, 2024
2 checks passed
@raphael
Copy link
Member

raphael commented Jan 6, 2024

Thank you for the awesome contribution!

raphael pushed a commit that referenced this pull request Jan 8, 2024
… System (#331)

* initial commit

* Empty-Commit

* add readme file (still need to fill out)

* tester readme update

* Trying out a workflow to run integration tests against local binaries

* Add proto install to /example/weather/scripts/setup

* fix integration.yaml

* disable mono on ubuntu

* move mono stop

* Try to find out what's running on 8084

* Trying to disable mono?

* trying to stop mono 2

* add a sleep after stop/disable?

* add some echo

* see if stop/disable mono fails

* add back in || true, change front ports to see if this even works at all

* oops forgot to change int test port

* try no send to dev null?

* sleep before testing

* take out netstat

* sleep longer? give time for docker to do work to get grafana?

* remove dev>null again... :\

* sleep 60 :(

* Implement review comment changes

* Fix runTests check for filtering if

* Empty-Commit

* try starting each service individually, check fo rmono

* just KILL mono?

* back to 8084, check all ports

* fix typo

* add flag to turn off grafana for services (for CI testing)

* clean up integration.yaml script

* review fixes

* Get Stack Trace to Err Log on Panic

* small fixes for style

* protoc -> 25.1, better wait in integration.yaml

* Add synchronous testing feature

* Make one of the synchronous as an example

* move func maps to service definition
raphael added a commit that referenced this pull request Jan 8, 2024
* Switch to using OpenTelemetry for both tracing and metrics

This commit replaces the `metrics` and `trace` packages with a new `clue` package that leverages OpenTelemetry for instrumenting metrics and traces.

See the README for instructions on how to upgrade.

* Add tests

* Remove coupling on Goa middleware

* Use GRPC stat.handler for tracing in gRPC (#349)

This replaces the deprecated use of interceptors.
See open-telemetry/opentelemetry-go-contrib#3002.

Remove use of Goa request ID middleware. This is superseded by logging span IDs.

* Add example `tester` service to show API Integration Testing of a Goa System (#331)

* initial commit

* Empty-Commit

* add readme file (still need to fill out)

* tester readme update

* Trying out a workflow to run integration tests against local binaries

* Add proto install to /example/weather/scripts/setup

* fix integration.yaml

* disable mono on ubuntu

* move mono stop

* Try to find out what's running on 8084

* Trying to disable mono?

* trying to stop mono 2

* add a sleep after stop/disable?

* add some echo

* see if stop/disable mono fails

* add back in || true, change front ports to see if this even works at all

* oops forgot to change int test port

* try no send to dev null?

* sleep before testing

* take out netstat

* sleep longer? give time for docker to do work to get grafana?

* remove dev>null again... :\

* sleep 60 :(

* Implement review comment changes

* Fix runTests check for filtering if

* Empty-Commit

* try starting each service individually, check fo rmono

* just KILL mono?

* back to 8084, check all ports

* fix typo

* add flag to turn off grafana for services (for CI testing)

* clean up integration.yaml script

* review fixes

* Get Stack Trace to Err Log on Panic

* small fixes for style

* protoc -> 25.1, better wait in integration.yaml

* Add synchronous testing feature

* Make one of the synchronous as an example

* move func maps to service definition

* Remove use of legacy flag

---------

Co-authored-by: Jason Borneman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants