mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-06 17:01:30 +00:00
add flaky and delays for testing
This commit is contained in:
parent
d2278b7e2e
commit
9ea23b5c03
@ -124,6 +124,8 @@ There is a `docker-compose.yaml` in this directory. <br/>
|
||||
Change your terminal to this folder and run:
|
||||
|
||||
```
|
||||
cd tracing
|
||||
|
||||
docker-compose build
|
||||
|
||||
docker-compose up
|
||||
|
@ -82,7 +82,6 @@ func main() {
|
||||
|
||||
span, _ := opentracing.StartSpanFromContext(ctx, "videos-api GET")
|
||||
|
||||
|
||||
v := videos{}
|
||||
|
||||
req, err := http.NewRequest("GET", "http://videos-api:10010/" + playlists[pi].Videos[vi].Id, nil)
|
||||
|
@ -7,9 +7,10 @@ import (
|
||||
"github.com/go-redis/redis/v8"
|
||||
"fmt"
|
||||
"context"
|
||||
"time"
|
||||
"strings"
|
||||
"os"
|
||||
"math/rand"
|
||||
|
||||
"github.com/opentracing/opentracing-go"
|
||||
"github.com/uber/jaeger-client-go"
|
||||
"github.com/uber/jaeger-client-go/config"
|
||||
@ -25,6 +26,7 @@ var environment = os.Getenv("ENVIRONMENT")
|
||||
var redis_host = os.Getenv("REDIS_HOST")
|
||||
var redis_port = os.Getenv("REDIS_PORT")
|
||||
var flaky = os.Getenv("FLAKY")
|
||||
var delay = os.Getenv("DELAY")
|
||||
|
||||
var ctx = context.Background()
|
||||
var rdb *redis.Client
|
||||
@ -66,7 +68,7 @@ func main() {
|
||||
span := tracer.StartSpan("/id GET", ext.RPCServerOption(spanCtx))
|
||||
defer span.Finish()
|
||||
|
||||
if flaky == "true"{
|
||||
if flaky == "true" {
|
||||
if rand.Intn(90) < 30 {
|
||||
panic("flaky error occurred ")
|
||||
}
|
||||
@ -75,6 +77,10 @@ func main() {
|
||||
ctx := opentracing.ContextWithSpan(context.Background(), span)
|
||||
video := video(w,r,p, ctx)
|
||||
|
||||
if strings.Contains(video, "jM36M39MA3I") && delay == "true" {
|
||||
time.Sleep(6 * time.Second)
|
||||
}
|
||||
|
||||
cors(w)
|
||||
fmt.Fprintf(w, "%s", video)
|
||||
|
||||
|
@ -22,6 +22,14 @@ services:
|
||||
- 81:10010
|
||||
networks:
|
||||
- tracing
|
||||
playlists-db:
|
||||
container_name: playlists-db
|
||||
image: redis:6.0-alpine
|
||||
command: [ "redis-server" , "--dir", "/tmp", "--appendonly", "yes"]
|
||||
volumes:
|
||||
- ./applications-go/playlists-db/appendonly.aof:/tmp/appendonly.aof
|
||||
networks:
|
||||
- tracing
|
||||
videos-api:
|
||||
container_name: videos-api
|
||||
image: aimvector/jaeger-tracing:videos-api-1.0.0
|
||||
@ -31,6 +39,8 @@ services:
|
||||
- "ENVIRONMENT=DEBUG"
|
||||
- "REDIS_HOST=videos-db"
|
||||
- "REDIS_PORT=6379"
|
||||
- "DELAY=true"
|
||||
#- "FLAKY=true"
|
||||
ports:
|
||||
- 82:10010
|
||||
networks:
|
||||
@ -43,14 +53,6 @@ services:
|
||||
- ./applications-go/videos-db/appendonly.aof:/tmp/appendonly.aof
|
||||
networks:
|
||||
- tracing
|
||||
playlists-db:
|
||||
container_name: playlists-db
|
||||
image: redis:6.0-alpine
|
||||
command: [ "redis-server" , "--dir", "/tmp", "--appendonly", "yes"]
|
||||
volumes:
|
||||
- ./applications-go/playlists-db/appendonly.aof:/tmp/appendonly.aof
|
||||
networks:
|
||||
- tracing
|
||||
jaeger:
|
||||
container_name: jaeger
|
||||
image: jaegertracing/all-in-one:latest
|
||||
|
Loading…
x
Reference in New Issue
Block a user