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:
|
Change your terminal to this folder and run:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
cd tracing
|
||||||
|
|
||||||
docker-compose build
|
docker-compose build
|
||||||
|
|
||||||
docker-compose up
|
docker-compose up
|
||||||
|
@ -82,7 +82,6 @@ func main() {
|
|||||||
|
|
||||||
span, _ := opentracing.StartSpanFromContext(ctx, "videos-api GET")
|
span, _ := opentracing.StartSpanFromContext(ctx, "videos-api GET")
|
||||||
|
|
||||||
|
|
||||||
v := videos{}
|
v := videos{}
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", "http://videos-api:10010/" + playlists[pi].Videos[vi].Id, nil)
|
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"
|
"github.com/go-redis/redis/v8"
|
||||||
"fmt"
|
"fmt"
|
||||||
"context"
|
"context"
|
||||||
|
"time"
|
||||||
|
"strings"
|
||||||
"os"
|
"os"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
|
||||||
"github.com/opentracing/opentracing-go"
|
"github.com/opentracing/opentracing-go"
|
||||||
"github.com/uber/jaeger-client-go"
|
"github.com/uber/jaeger-client-go"
|
||||||
"github.com/uber/jaeger-client-go/config"
|
"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_host = os.Getenv("REDIS_HOST")
|
||||||
var redis_port = os.Getenv("REDIS_PORT")
|
var redis_port = os.Getenv("REDIS_PORT")
|
||||||
var flaky = os.Getenv("FLAKY")
|
var flaky = os.Getenv("FLAKY")
|
||||||
|
var delay = os.Getenv("DELAY")
|
||||||
|
|
||||||
var ctx = context.Background()
|
var ctx = context.Background()
|
||||||
var rdb *redis.Client
|
var rdb *redis.Client
|
||||||
@ -66,7 +68,7 @@ func main() {
|
|||||||
span := tracer.StartSpan("/id GET", ext.RPCServerOption(spanCtx))
|
span := tracer.StartSpan("/id GET", ext.RPCServerOption(spanCtx))
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
if flaky == "true"{
|
if flaky == "true" {
|
||||||
if rand.Intn(90) < 30 {
|
if rand.Intn(90) < 30 {
|
||||||
panic("flaky error occurred ")
|
panic("flaky error occurred ")
|
||||||
}
|
}
|
||||||
@ -75,6 +77,10 @@ func main() {
|
|||||||
ctx := opentracing.ContextWithSpan(context.Background(), span)
|
ctx := opentracing.ContextWithSpan(context.Background(), span)
|
||||||
video := video(w,r,p, ctx)
|
video := video(w,r,p, ctx)
|
||||||
|
|
||||||
|
if strings.Contains(video, "jM36M39MA3I") && delay == "true" {
|
||||||
|
time.Sleep(6 * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
cors(w)
|
cors(w)
|
||||||
fmt.Fprintf(w, "%s", video)
|
fmt.Fprintf(w, "%s", video)
|
||||||
|
|
||||||
|
@ -22,6 +22,14 @@ services:
|
|||||||
- 81:10010
|
- 81:10010
|
||||||
networks:
|
networks:
|
||||||
- tracing
|
- 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:
|
videos-api:
|
||||||
container_name: videos-api
|
container_name: videos-api
|
||||||
image: aimvector/jaeger-tracing:videos-api-1.0.0
|
image: aimvector/jaeger-tracing:videos-api-1.0.0
|
||||||
@ -31,6 +39,8 @@ services:
|
|||||||
- "ENVIRONMENT=DEBUG"
|
- "ENVIRONMENT=DEBUG"
|
||||||
- "REDIS_HOST=videos-db"
|
- "REDIS_HOST=videos-db"
|
||||||
- "REDIS_PORT=6379"
|
- "REDIS_PORT=6379"
|
||||||
|
- "DELAY=true"
|
||||||
|
#- "FLAKY=true"
|
||||||
ports:
|
ports:
|
||||||
- 82:10010
|
- 82:10010
|
||||||
networks:
|
networks:
|
||||||
@ -43,14 +53,6 @@ services:
|
|||||||
- ./applications-go/videos-db/appendonly.aof:/tmp/appendonly.aof
|
- ./applications-go/videos-db/appendonly.aof:/tmp/appendonly.aof
|
||||||
networks:
|
networks:
|
||||||
- tracing
|
- 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:
|
jaeger:
|
||||||
container_name: jaeger
|
container_name: jaeger
|
||||||
image: jaegertracing/all-in-one:latest
|
image: jaegertracing/all-in-one:latest
|
||||||
|
Loading…
x
Reference in New Issue
Block a user