Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 34 additions & 60 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ jobs:
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
if [[ "$LABELS" == *"devmesh"* ]]; then
echo "Found devmesh label"
NAMESPACE="hotrod-devmesh"
else
echo "Using default namespace"
NAMESPACE="hotrod-istio"
fi
echo "Using namespace=${NAMESPACE}"
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV"
Expand All @@ -142,7 +142,11 @@ jobs:
-f - \
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml

- name: Run Tests
- name: Run Smart Tests
run: |
signadot st run --sandbox=${SANDBOX_NAME} --publish

- name: Run Integration Tests using Signadot Local Proxy
run: |
# Run the proxy
echo "Starting signadot proxy..."
Expand Down Expand Up @@ -194,12 +198,12 @@ jobs:
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
if [[ "$LABELS" == *"devmesh"* ]]; then
echo "Found devmesh label"
NAMESPACE="hotrod-devmesh"
else
echo "Using default namespace"
NAMESPACE="hotrod-istio"
fi
echo "Using namespace=${NAMESPACE}"
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV"
Expand All @@ -217,27 +221,9 @@ jobs:
-f - \
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml

- name: Run Tests
- name: Run Smart Tests
run: |
# Run the proxy
echo "Starting signadot proxy..."
signadot local proxy --sandbox ${SANDBOX_NAME} \
--map http://frontend.${NAMESPACE}:8080@localhost:38080 > /tmp/signadot-proxy.log &
PROXY_PID=$!
sleep 1
cat /tmp/signadot-proxy.log

# Run integration tests
echo "Executing tests..."
go install github.com/jstemmer/go-junit-report/v2@latest
TEST_FRONTEND_ADDR=localhost:38080 TEST_TARGET_WORKLOAD=frontend TEST_SANDBOX_NAME=${SANDBOX_NAME} go test -v \
${GITHUB_WORKSPACE}/services/frontend/ | go-junit-report -set-exit-code -out integration-report.xml

# Stop the proxy
echo "Stopping signadot proxy..."
cat /tmp/signadot-proxy.log
kill ${PROXY_PID}

signadot st run --sandbox=${SANDBOX_NAME} --publish

sandbox-location:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -265,12 +251,12 @@ jobs:
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
if [[ "$LABELS" == *"devmesh"* ]]; then
echo "Found devmesh label"
NAMESPACE="hotrod-devmesh"
else
echo "Using default namespace"
NAMESPACE="hotrod-istio"
fi
echo "Using namespace=${NAMESPACE}"
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV"
Expand All @@ -288,6 +274,11 @@ jobs:
-f - \
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml


- name: Run Smart Tests
run: |
signadot st run --sandbox=${SANDBOX_NAME} --publish

sandbox-driver:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'pull_request' && needs.changes.outputs.driver == 'true' }}
Expand All @@ -314,12 +305,12 @@ jobs:
echo "Checking for labels..."
LABELS="${{ toJSON(github.event.pull_request.labels.*.name) }}"
echo "Labels on PR: $LABELS"
if [[ "$LABELS" == *"istio"* ]]; then
echo "Found istio label"
NAMESPACE="hotrod-istio"
else
echo "istio label not found"
if [[ "$LABELS" == *"devmesh"* ]]; then
echo "Found devmesh label"
NAMESPACE="hotrod-devmesh"
else
echo "Using default namespace"
NAMESPACE="hotrod-istio"
fi
echo "Using namespace=${NAMESPACE}"
echo "NAMESPACE=${NAMESPACE}" >> "$GITHUB_ENV"
Expand All @@ -337,23 +328,6 @@ jobs:
-f - \
< ${GITHUB_WORKSPACE}/.signadot/sbx-gh-template.yaml

- name: Run Tests
- name: Run Smart Tests
run: |
# Run the proxy
echo "Starting signadot proxy..."
signadot local proxy --sandbox ${SANDBOX_NAME} \
--map http://frontend.${NAMESPACE}:8080@localhost:38080 > /tmp/signadot-proxy.log &
PROXY_PID=$!
sleep 1
cat /tmp/signadot-proxy.log

# Run integration tests
echo "Executing tests..."
go install github.com/jstemmer/go-junit-report/v2@latest
TEST_FRONTEND_ADDR=localhost:38080 TEST_TARGET_WORKLOAD=driver TEST_SANDBOX_NAME=${SANDBOX_NAME} go test -v \
${GITHUB_WORKSPACE}/services/frontend/ | go-junit-report -set-exit-code -out integration-report.xml

# Stop the proxy
echo "Stopping signadot proxy..."
cat /tmp/signadot-proxy.log
kill ${PROXY_PID}
signadot st run --sandbox=${SANDBOX_NAME} --publish
2 changes: 2 additions & 0 deletions .signadot/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
smart_tests:
- smart-tests/
3 changes: 0 additions & 3 deletions k8s/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,3 @@ resources:
- driver.yaml
- route.yaml

images:
- name: signadot/hotrod
newTag: quickstart-v5-fix
6 changes: 0 additions & 6 deletions k8s/overlays/prod/quickstart/kustomization.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/config/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func GetRouteCalcDelay() time.Duration {
return dur
}

// the standard deviation
// GetRouteCalcStdDev calculates the standard deviation
func GetRouteCalcStdDev() time.Duration {
return GetRouteCalcDelay() / 4
}
1 change: 1 addition & 0 deletions services/driver/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Consumer struct {
func newConsumer(ctx context.Context, tracerProvider trace.TracerProvider,
logger log.Factory) *Consumer {
// create a routesapi baseline watched instance
// TODO: remove this in case we're not running with Signadot
routing, err := watched.BaselineWatchedFromEnv()
if err != nil {
panic(err)
Expand Down
6 changes: 3 additions & 3 deletions services/frontend/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ type ConfigOptions struct {

// NewServer creates a new frontend.Server
func NewServer(options ConfigOptions, logger log.Factory) *Server {
// get a tracer provider for the frontend
// get tracer provider for the frontend
tracerProvider := tracing.InitOTEL("frontend", config.GetOtelExporterType(),
config.GetMetricsFactory(), logger)

// get a location client
// get location client
locationClient := location.NewClient(tracerProvider, logger, options.LocationHostPort)

// get a notification handler
// get notification handler
notificationHandler := notifications.NewNotificationHandler(tracerProvider, logger)

// get a dispatcher
Expand Down
4 changes: 2 additions & 2 deletions services/location/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ type Server struct {
database *database
}

// NewServer creates a new location.Server
// NewServer creates new location.Server
func NewServer(hostPort string, logger log.Factory) *Server {
// get a tracer provider for the location
// get tracer provider for the location
tracerProvider := tracing.InitOTEL("location", config.GetOtelExporterType(),
config.GetMetricsFactory(), logger)

Expand Down
2 changes: 2 additions & 0 deletions smart-tests/frontend/.labels
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
team=frontend
app=hotrod
33 changes: 33 additions & 0 deletions smart-tests/frontend/post-frontend-dispatch.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Smart Test for Dispatch API

# Create a Smart Test Check
ck = smart_test.check("dispatch-api-response")

# Define the request payload
payload = {
"sessionID": 1,
"requestID": 1,
"pickupLocationID": 1,
"dropoffLocationID": 731
}

# Send the POST request with capture enabled
resp = http.post(
url="http://frontend.hotrod-istio.svc:8080/dispatch",
json_body=payload,
capture=True,
name="dispatchRequest"
)

# Validate the response
if resp.status_code != 200:
ck.error("Unexpected status code: {}", resp.status_code)

# Parse JSON response
response_json = resp.json()
if type(response_json) != "dict":
ck.error("Unexpected response format: expected JSON object, got {}", type(response_json))

# Additional response validation (if applicable)
if "success" in response_json and not response_json["success"]:
ck.error("Dispatch request failed, response: {}", response_json)
2 changes: 2 additions & 0 deletions smart-tests/location/.labels
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
team=location
app=hotrod
12 changes: 12 additions & 0 deletions smart-tests/location/get-location.star
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
res = http.get(
url="http://location.hotrod-istio.svc:8081/locations", # can also be cluster internal URLs like http://name.namespace.svc
capture=True, # enables SmartDiff
name="getLocations"
)

ck = smart_test.check("get-location-status")
if res.status_code != 200:
ck.error("bad status code: {}", res.status_code)

print(res.status_code)
print(res.body())
Loading