You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/11/08 09:47:18 UTC

[skywalking-showcase] branch main updated: Add load generator

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

kezhenxu94 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-showcase.git


The following commit(s) were added to refs/heads/main by this push:
     new 259c04a  Add load generator
259c04a is described below

commit 259c04a74ee8f41273a25dcae85400b4dc10f9a5
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Nov 8 17:47:08 2021 +0800

    Add load generator
---
 deploy/platform/docker/docker-compose.agent.yaml   |  7 ++++
 .../kubernetes/feature-agent/resources.yaml        | 21 ++++++++++++
 services/app/server/index.js                       |  1 +
 services/load-gen/Dockerfile                       | 28 ++++++++++++++++
 services/load-gen/Makefile                         | 32 ++++++++++++++++++
 services/load-gen/loadgen.py                       | 39 ++++++++++++++++++++++
 services/load-gen/requirements.txt                 |  1 +
 7 files changed, 129 insertions(+)

diff --git a/deploy/platform/docker/docker-compose.agent.yaml b/deploy/platform/docker/docker-compose.agent.yaml
index e64547d..1dfc4b3 100644
--- a/deploy/platform/docker/docker-compose.agent.yaml
+++ b/deploy/platform/docker/docker-compose.agent.yaml
@@ -86,5 +86,12 @@ services:
       oap:
         condition: service_healthy
 
+  loadgen:
+    image: ${HUB}/load-gen:${TAG}
+    networks: [ sw ]
+    depends_on:
+      app:
+        condition: service_healthy
+
 networks:
   sw:
diff --git a/deploy/platform/kubernetes/feature-agent/resources.yaml b/deploy/platform/kubernetes/feature-agent/resources.yaml
index c12e3d1..35a80d3 100644
--- a/deploy/platform/kubernetes/feature-agent/resources.yaml
+++ b/deploy/platform/kubernetes/feature-agent/resources.yaml
@@ -179,3 +179,24 @@ spec:
               value: app
             - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
               value: oap:11800
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: loadgen-deployment
+  labels:
+    app: loadgen
+spec:
+  replicas: 1
+  selector:
+    matchLabels:
+      app: loadgen
+  template:
+    metadata:
+      labels:
+        app: loadgen
+    spec:
+      containers:
+        - name: app
+          image: ${HUB}/load-gen:${TAG}
diff --git a/services/app/server/index.js b/services/app/server/index.js
index 49b355b..0dedbfd 100644
--- a/services/app/server/index.js
+++ b/services/app/server/index.js
@@ -29,6 +29,7 @@ const oapHttpAddress = 'http://oap:12800'
 agent.start({
     serviceName: 'app',
     maxBufferSize: 1000,
+    traceIgnorePath: '/browser/**,/v3/**,/health',
 });
 
 const PORT = process.env.PORT || 80;
diff --git a/services/load-gen/Dockerfile b/services/load-gen/Dockerfile
new file mode 100644
index 0000000..3e9bbf6
--- /dev/null
+++ b/services/load-gen/Dockerfile
@@ -0,0 +1,28 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+FROM selenium/standalone-firefox:94.0
+
+WORKDIR /home/seluser
+
+COPY requirements.txt requirements.txt
+COPY loadgen.py loadgen.py
+
+RUN sudo apt-get update && sudo apt-get install -y python3-pip
+RUN pip3 install -r requirements.txt
+
+CMD python3 loadgen.py
diff --git a/services/load-gen/Makefile b/services/load-gen/Makefile
new file mode 100644
index 0000000..05dc0ff
--- /dev/null
+++ b/services/load-gen/Makefile
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+include ../../Makefile.in
+
+.PHONY: build
+build:
+
+.PHONY: docker docker.build docker.push
+
+docker: docker.push
+
+docker.build:
+	docker build . -t $(HUB)/load-gen:$(TAG)
+
+docker.push: docker.build
+	docker push $(HUB)/load-gen:$(TAG)
diff --git a/services/load-gen/loadgen.py b/services/load-gen/loadgen.py
new file mode 100644
index 0000000..4fd4338
--- /dev/null
+++ b/services/load-gen/loadgen.py
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import os
+import time
+import traceback
+
+from selenium import webdriver
+from selenium.webdriver.firefox.options import Options as FirefoxOptions
+
+url = os.getenv('URL', 'http://app')
+
+options = FirefoxOptions()
+options.add_argument("--headless")
+driver = webdriver.Firefox(options=options)
+
+while True:
+    print(f'Sending traffic to {url}')
+    # noinspection PyBroadException
+    try:
+        driver.get(url)
+    except Exception:
+        traceback.print_exc()
+    finally:
+        time.sleep(10)
diff --git a/services/load-gen/requirements.txt b/services/load-gen/requirements.txt
new file mode 100644
index 0000000..3421235
--- /dev/null
+++ b/services/load-gen/requirements.txt
@@ -0,0 +1 @@
+selenium==4.0.0