You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by zh...@apache.org on 2022/01/27 03:03:19 UTC

[skywalking-agent-test-tool] branch push.branches created (now 7dbd0ed)

This is an automated email from the ASF dual-hosted git repository.

zhangwei24 pushed a change to branch push.branches
in repository https://gitbox.apache.org/repos/asf/skywalking-agent-test-tool.git.


      at 7dbd0ed  Build linux/arm64 and linux/arm/v7 docker image

This branch includes the following new commits:

     new 7dbd0ed  Build linux/arm64 and linux/arm/v7 docker image

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[skywalking-agent-test-tool] 01/01: Build linux/arm64 and linux/arm/v7 docker image

Posted by zh...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

zhangwei24 pushed a commit to branch push.branches
in repository https://gitbox.apache.org/repos/asf/skywalking-agent-test-tool.git

commit 7dbd0ed7db4e0a377657191563f904d7e5aee731
Author: zhangwei <zh...@apache.org>
AuthorDate: Thu Jan 27 11:03:08 2022 +0800

    Build linux/arm64 and linux/arm/v7 docker image
---
 .github/workflows/publish-docker.yaml              | 11 ++--
 Makefile                                           | 70 ++++++++++++----------
 .../Dockerfile}                                    |  2 +-
 .../mockcollector/mock/MockMeterReportService.java | 26 ++++++++
 4 files changed, 71 insertions(+), 38 deletions(-)

diff --git a/.github/workflows/publish-docker.yaml b/.github/workflows/publish-docker.yaml
index ae6a526..c120519 100644
--- a/.github/workflows/publish-docker.yaml
+++ b/.github/workflows/publish-docker.yaml
@@ -20,6 +20,7 @@ on:
   push:
     branches:
       - master
+      - push.branches
 
 env:
   SKIP_TEST: true
@@ -51,7 +52,9 @@ jobs:
           registry: ${{ env.HUB }}
           username: ${{ github.actor }}
           password: ${{ secrets.GITHUB_TOKEN }}
-      - name: Build docker image
-        run: |
-          make docker || make docker
-          make docker.push || make docker.push
+      - name: Set up QEMU
+        uses: docker/setup-qemu-action@v1
+      - name: Set up Docker Buildx
+        uses: docker/setup-buildx-action@v1
+      - name: Build and push docker images
+        run: make build.mock-collector docker.push
diff --git a/Makefile b/Makefile
index d64b766..35ff894 100644
--- a/Makefile
+++ b/Makefile
@@ -16,51 +16,55 @@
 
 SHELL := /bin/bash -o pipefail
 
-export TOOLS_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+TOOL_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+CONTEXT ?= ${TOOL_ROOT}/dist
+SKIP_TEST ?= false
+DIST ?= skywalking-mock-collector.tar.gz
 
-export TOOLS_OUT:=${TOOLS_ROOT}/dist
+.PHONY: build.mock-collector
+build.mock-collector:
+	cd $(TOOL_ROOT) && ./mvnw -B -Dmaven.test.skip=$(SKIP_TEST) clean package
 
-SKIP_TEST?=false
+DOCKER_BUILD_TOP:=${CONTEXT}/docker_build
 
-HUB?=skywalking
+HUB ?= skywalking
+MOCK_COLLECTOR_NAME ?= mock-collector
+TAG ?= latest
 
-TAG?=latest
+.PHONY: docker build.mock-collector
 
-DOCKER_BUILD_TOP:=${TOOLS_OUT}/docker_build
+docker: build.mock-collector docker.all
 
 DOCKER_TARGETS:=docker.mock-collector
 
-.PHONY: build docker docker.mock docker.push
+%.mock-collector: NAME = $(MOCK_COLLECTOR_NAME)
 
-build:
-	cd $(TOOLS_ROOT) && ./mvnw -B -Dmaven.test.skip=$(SKIP_TEST) clean package
+docker.%: PLATFORMS =
+docker.%: LOAD_OR_PUSH = --load
+push.%: PLATFORMS = --platform linux/amd64,linux/arm64,linux/arm/v7
+push.%: LOAD_OR_PUSH = --push
 
-docker: build docker.mock-collector
+docker.% push.docker.%: $(CONTEXT)/$(DIST) $(TOOL_ROOT)/docker/%/*
+	$(DOCKER_RULE)
 
-docker.mock-collector: $(TOOLS_OUT)/skywalking-mock-collector.tar.gz
-docker.mock-collector: $(TOOLS_ROOT)/docker/Dockerfile.mock-collector
-		$(DOCKER_RULE)
+docker.all: $(DOCKER_TARGETS)
+docker.push: $(DOCKER_TARGETS:%=push.%)
 
-# $@ is the name of the target
 # $^ the name of the dependencies for the target
 # Rule Steps #
 ##############
-# 1. Make a directory $(DOCKER_BUILD_TOP)/%@
-# 2. This rule uses cp to copy all dependency filenames into into $(DOCKER_BUILD_TOP/$@
-# 3. This rule then changes directories to $(DOCKER_BUID_TOP)/$@
-# 4. This rule runs $(BUILD_PRE) prior to any docker build and only if specified as a dependency variable
-
-DOCKER_RULE=time (mkdir -p $(DOCKER_BUILD_TOP)/$@ && cp -r $^ $(DOCKER_BUILD_TOP)/$@ && cd $(DOCKER_BUILD_TOP)/$@ && $(BUILD_PRE) docker build --no-cache -t $(HUB)/$(subst docker.,,$@):$(TAG) -f Dockerfile$(suffix $@) .)
-
-# for each docker.XXX target create a push.docker.XXX target that pushes
-# the local docker image to another hub
-# a possible optimization is to use tag.$(TGT) as a dependency to do the tag for us
-$(foreach TGT,$(DOCKER_TARGETS),$(eval push.$(TGT): | $(TGT) ; \
-	time (docker push $(HUB)/$(subst docker.,,$(TGT)):$(TAG))))
-
-# create a DOCKER_PUSH_TARGETS that's each of DOCKER_TARGETS with a push. prefix
-DOCKER_PUSH_TARGETS:=
-$(foreach TGT,$(DOCKER_TARGETS),$(eval DOCKER_PUSH_TARGETS+=push.$(TGT)))
-
-# Will build and push docker images.
-docker.push: $(DOCKER_PUSH_TARGETS)
\ No newline at end of file
+# 1. Make a directory $(DOCKER_BUILD_TOP)/$(NAME)
+# 2. This rule uses cp to copy all dependency filenames into into $(DOCKER_BUILD_TOP/$(NAME)
+# 3. This rule finally runs docker build passing $(BUILD_ARGS) to docker if they are specified as a dependency variable
+
+define DOCKER_RULE
+	mkdir -p $(DOCKER_BUILD_TOP)/$(NAME)
+	cp -r $^ $(DOCKER_BUILD_TOP)/$(NAME)
+	docker buildx create --use --driver docker-container --name skywalking_main > /dev/null 2>&1 || true
+	docker buildx build $(PLATFORMS) $(LOAD_OR_PUSH) \
+		--no-cache $(BUILD_ARGS) \
+		-t $(HUB)/$(NAME):$(TAG) \
+		-t $(HUB)/$(NAME):latest \
+		$(DOCKER_BUILD_TOP)/$(NAME)
+	docker buildx rm skywalking_main || true
+endef
\ No newline at end of file
diff --git a/docker/Dockerfile.mock-collector b/docker/mock-collector/Dockerfile
similarity index 93%
rename from docker/Dockerfile.mock-collector
rename to docker/mock-collector/Dockerfile
index b9205d2..0b4f37f 100644
--- a/docker/Dockerfile.mock-collector
+++ b/docker/mock-collector/Dockerfile
@@ -15,7 +15,7 @@
 # limitations under the License.
 #
 
-FROM openjdk:8
+FROM eclipse-temurin:8u312-b07-jre-focal
 
 WORKDIR /skywalking-mock-collector
 
diff --git a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/MockMeterReportService.java b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/MockMeterReportService.java
index e191499..bd78772 100644
--- a/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/MockMeterReportService.java
+++ b/mock-collector/src/main/java/org/apache/skywalking/plugin/test/mockcollector/mock/MockMeterReportService.java
@@ -21,6 +21,7 @@ import io.grpc.stub.StreamObserver;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.skywalking.apm.network.common.v3.Commands;
 import org.apache.skywalking.apm.network.language.agent.v3.MeterData;
+import org.apache.skywalking.apm.network.language.agent.v3.MeterDataCollection;
 import org.apache.skywalking.apm.network.language.agent.v3.MeterReportServiceGrpc;
 import org.apache.skywalking.plugin.test.mockcollector.util.MeterHandler;
 
@@ -49,4 +50,29 @@ public class MockMeterReportService extends MeterReportServiceGrpc.MeterReportSe
             }
         };
     }
+
+    @Override
+    public StreamObserver<MeterDataCollection> collectBatch(final StreamObserver<Commands> responseObserver) {
+        final MeterHandler.Parser parser = MeterHandler.createParser();
+        return new StreamObserver<MeterDataCollection>() {
+            @Override
+            public void onNext(final MeterDataCollection meterDataCollection) {
+                for (MeterData meterData : meterDataCollection.getMeterDataList()) {
+                    parser.parse(meterData);
+                }
+            }
+
+            @Override
+            public void onError(final Throwable throwable) {
+                log.error(throwable.getMessage(), throwable);
+                responseObserver.onCompleted();
+            }
+
+            @Override
+            public void onCompleted() {
+                responseObserver.onNext(Commands.newBuilder().build());
+                responseObserver.onCompleted();
+            }
+        };
+    }
 }