From bf87800a86b3689648e3192b958f1395ba391223 Mon Sep 17 00:00:00 2001 From: Roland Schilter Date: Tue, 6 Jun 2017 15:32:39 +0100 Subject: [PATCH 1/6] Remove dead prog/main_test.go test Is excluded from tests and does not compile. --- tools/test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test b/tools/test index 1497e7a2ae..d0fde821f3 100755 --- a/tools/test +++ b/tools/test @@ -74,7 +74,7 @@ fail=0 if [ -z "$TESTDIRS" ]; then # NB: Relies on paths being prefixed with './'. - TESTDIRS=($(git ls-files -- '*_test.go' | grep -vE '^(vendor|prog|experimental)/' | xargs -n1 dirname | sort -u | sed -e 's|^|./|')) + TESTDIRS=($(git ls-files -- '*_test.go' | grep -vE '^(vendor|experimental)/' | xargs -n1 dirname | sort -u | sed -e 's|^|./|')) else # TESTDIRS on the right side is not really an array variable, it # is just a string with spaces, but it is written like that to From 61471fb833d67fa48817c74509ac506be1e832ca Mon Sep 17 00:00:00 2001 From: Roland Schilter Date: Tue, 6 Jun 2017 15:48:09 +0100 Subject: [PATCH 2/6] Re-introduce fixed test --- prog/main_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/prog/main_test.go b/prog/main_test.go index 0e8d57ebfb..4fbbbe5836 100644 --- a/prog/main_test.go +++ b/prog/main_test.go @@ -8,6 +8,25 @@ import ( "github.com/stretchr/testify/assert" ) +func TestMakeContainerFiltersFromFlags(t *testing.T) { + containerLabelFlags := containerLabelFiltersFlag{exclude: false} + containerLabelFlags.Set(`title1:label=1`) + containerLabelFlags.Set(`ti\:tle2:lab\:el=2`) + containerLabelFlags.Set(`ti tile3:label=3`) + + err := containerLabelFlags.Set(`just a string`) + assert.NotNil(t, err, "Invalid container label flag not detected") + + apiTopologyOptions := containerLabelFlags.apiTopologyOptions + assert.Equal(t, 3, len(apiTopologyOptions)) + assert.Equal(t, `title1`, apiTopologyOptions[0].Value) + assert.Equal(t, `label=1`, apiTopologyOptions[0].Label) + assert.Equal(t, `ti:tle2`, apiTopologyOptions[1].Value) + assert.Equal(t, `lab:el=2`, apiTopologyOptions[1].Label) + assert.Equal(t, `ti tle3`, apiTopologyOptions[2].Value) + assert.Equal(t, `label=3`, apiTopologyOptions[2].Label) +} + func TestLogCensoredArgs(t *testing.T) { setupFlags(&flags{}) args := []string{ From c2b9cadad9b65f9da42c78264215191ad167a033 Mon Sep 17 00:00:00 2001 From: Roland Schilter Date: Tue, 6 Jun 2017 16:24:12 +0100 Subject: [PATCH 3/6] Fix assertions --- prog/main_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/prog/main_test.go b/prog/main_test.go index 4fbbbe5836..ca238c5073 100644 --- a/prog/main_test.go +++ b/prog/main_test.go @@ -14,17 +14,17 @@ func TestMakeContainerFiltersFromFlags(t *testing.T) { containerLabelFlags.Set(`ti\:tle2:lab\:el=2`) containerLabelFlags.Set(`ti tile3:label=3`) - err := containerLabelFlags.Set(`just a string`) + err := containerLabelFlags.Set("just a string") assert.NotNil(t, err, "Invalid container label flag not detected") apiTopologyOptions := containerLabelFlags.apiTopologyOptions assert.Equal(t, 3, len(apiTopologyOptions)) - assert.Equal(t, `title1`, apiTopologyOptions[0].Value) - assert.Equal(t, `label=1`, apiTopologyOptions[0].Label) - assert.Equal(t, `ti:tle2`, apiTopologyOptions[1].Value) - assert.Equal(t, `lab:el=2`, apiTopologyOptions[1].Label) - assert.Equal(t, `ti tle3`, apiTopologyOptions[2].Value) - assert.Equal(t, `label=3`, apiTopologyOptions[2].Label) + assert.Equal(t, "0", apiTopologyOptions[0].Value) + assert.Equal(t, "title1", apiTopologyOptions[0].Label) + assert.Equal(t, "1", apiTopologyOptions[1].Value) + assert.Equal(t, "ti:tle2", apiTopologyOptions[1].Label) + assert.Equal(t, "2", apiTopologyOptions[2].Value) + assert.Equal(t, "ti tile3", apiTopologyOptions[2].Label) } func TestLogCensoredArgs(t *testing.T) { From 5e557486e4b5d28d312f212aa36dff5ec84a26e5 Mon Sep 17 00:00:00 2001 From: Roland Schilter Date: Wed, 7 Jun 2017 10:52:19 +0100 Subject: [PATCH 4/6] Add ui dependenciesto tests rule --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 07d62e64ac..621aa7bb34 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,7 @@ $(RUNSVINIT): $(SCOPE_BACKEND_BUILD_UPTODATE) shell: $(SCOPE_BACKEND_BUILD_UPTODATE) /bin/bash -tests: $(SCOPE_BACKEND_BUILD_UPTODATE) $(CODECGEN_TARGETS) +tests: $(SCOPE_BACKEND_BUILD_UPTODATE) $(CODECGEN_TARGETS) prog/staticui/staticui.go prog/externalui/externalui.go ./tools/test -no-go-get lint: $(SCOPE_BACKEND_BUILD_UPTODATE) From 7d8448c586ea2743815558fab70b2f593bbc0fd5 Mon Sep 17 00:00:00 2001 From: Roland Schilter Date: Wed, 7 Jun 2017 14:41:03 +0100 Subject: [PATCH 5/6] Skip UI assets file embedding in backend image --- Makefile | 6 ++++-- backend/Dockerfile | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 621aa7bb34..ecced7c2b6 100644 --- a/Makefile +++ b/Makefile @@ -179,10 +179,12 @@ tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) else client/build/index.html: - cd client && npm run build + test "true" = "$(SCOPE_SKIP_UI_ASSETS)" && { mkdir -p client/build; } || \ + { cd client && npm run build; } client/build-external/index.html: - cd client && npm run build-external + test "true" = "$(SCOPE_SKIP_UI_ASSETS)" && { mkdir -p client/build-external; } || \ + { cd client && npm run build-external; } endif diff --git a/backend/Dockerfile b/backend/Dockerfile index 2764d9a0b9..8201216e62 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,6 +2,7 @@ FROM ubuntu:yakkety ENV GOPATH /go ENV GOVERSION 1.7 ENV PATH /go/bin:/usr/lib/go-${GOVERSION}/bin:/usr/bin:/bin:/usr/sbin:/sbin +ENV SCOPE_SKIP_UI_ASSETS true RUN apt-get update && \ apt-get install -y libpcap-dev python-requests time file shellcheck golang-${GOVERSION} git gcc-arm-linux-gnueabihf curl && \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* From 5f2e046b47b8d9fb4a2c6a299c301a7b916b08d7 Mon Sep 17 00:00:00 2001 From: Roland Schilter Date: Wed, 7 Jun 2017 15:35:39 +0100 Subject: [PATCH 6/6] Cleanup --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ecced7c2b6..d1c7d62895 100644 --- a/Makefile +++ b/Makefile @@ -179,11 +179,11 @@ tmp/weave-scope.tgz: $(shell find client/app -type f) $(SCOPE_UI_BUILD_UPTODATE) else client/build/index.html: - test "true" = "$(SCOPE_SKIP_UI_ASSETS)" && { mkdir -p client/build; } || \ + test "true" = "$(SCOPE_SKIP_UI_ASSETS)" && mkdir -p client/build || \ { cd client && npm run build; } client/build-external/index.html: - test "true" = "$(SCOPE_SKIP_UI_ASSETS)" && { mkdir -p client/build-external; } || \ + test "true" = "$(SCOPE_SKIP_UI_ASSETS)" && mkdir -p client/build-external || \ { cd client && npm run build-external; } endif