Skip to content

Commit 671a2f0

Browse files
authored
Fixed tutorial. (#1256)
Signed-off-by: bwplotka <[email protected]>
1 parent 90eb83b commit 671a2f0

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

tutorial/whatsup/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
.PHONY: help
32
help: ## Displays help.
43
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-z0-9A-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)

tutorial/whatsup/internal/acceptance_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
)
2828

2929
func TestAcceptance(t *testing.T) {
30-
resp, err := http.Get(fmt.Sprintf("http://localhost:%v/metrics", WhatsupPort))
30+
resp, err := http.Get(whatsupAddr(fmt.Sprintf("http://localhost:%v", WhatsupPort)) + "/metrics")
3131
testutil.Ok(t, err)
3232
defer resp.Body.Close()
3333

tutorial/whatsup/internal/common.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ type Config struct {
3737
TraceSamplingRatio float64 `yaml:"TraceSamplingRatio,omitempty"`
3838
}
3939

40+
func whatsupAddr(defAddress string) string {
41+
if a := os.Getenv("HOSTADDR"); a != "" {
42+
return a + ":" + WhatsupPort
43+
}
44+
return defAddress
45+
}
46+
4047
func ParseOptions(args []string) (Config, error) {
4148
c := Config{}
4249

tutorial/whatsup/internal/playground_test.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package internal
1919
import (
2020
"fmt"
2121
"os"
22+
"strings"
2223
"testing"
2324
"time"
2425

@@ -71,18 +72,27 @@ func TestPlayground(t *testing.T) {
7172
testutil.Ok(t, prom.SetConfig(prometheusConfig(map[string]string{
7273
"prometheus": prom.InternalEndpoint("http"),
7374
"jaeger": jaeger.InternalEndpoint("http.metrics"),
74-
"whatsup": fmt.Sprintf("host.docker.internal:%v", WhatsupPort),
75+
"whatsup": whatsupAddr(fmt.Sprintf("host.docker.internal:%v", WhatsupPort)),
7576
})))
7677
// Due to VM based docker setups (e.g. MacOS), file sharing can be slower - do more sighups just in case (noops if all good)
7778
prom.Exec(e2e.NewCommand("kill", "-SIGHUP", "1"))
7879
prom.Exec(e2e.NewCommand("kill", "-SIGHUP", "1"))
7980

8081
// Best effort.
81-
fmt.Println(e2einteractive.OpenInBrowser("http://" + jaeger.Endpoint("http.front")))
82-
fmt.Println(e2einteractive.OpenInBrowser("http://" + prom.Endpoint("http")))
82+
fmt.Println(e2einteractive.OpenInBrowser(convertToExternal("http://" + jaeger.Endpoint("http.front"))))
83+
fmt.Println(e2einteractive.OpenInBrowser(convertToExternal("http://" + prom.Endpoint("http"))))
8384
testutil.Ok(t, e2einteractive.RunUntilEndpointHitWithPort(19920))
8485
}
8586

87+
func convertToExternal(endpoint string) string {
88+
a := os.Getenv("HOSTADDR")
89+
if a == "" {
90+
return endpoint
91+
}
92+
// YOLO, fix and test.
93+
return fmt.Sprintf("%v:%v", a, strings.Split(endpoint, ":")[2])
94+
}
95+
8696
func prometheusConfig(jobToScrapeTargetAddress map[string]string) promconfig.Config {
8797
h, _ := os.Hostname()
8898
cfg := promconfig.Config{

0 commit comments

Comments
 (0)