-
Notifications
You must be signed in to change notification settings - Fork 0
feat: test stand #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
baydakov-georgiy
wants to merge
13
commits into
traffic_filtering
Choose a base branch
from
test_stand
base: traffic_filtering
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: test stand #126
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f26fe3c
building test stand
baydakov-georgiy 8595f23
refactor(test_stand): replace Ubuntu image with Yocto for QEMU VMs
baydakov-georgiy c3e276e
fix(controller): incorrect resp.Body.Close()
baydakov-georgiy b64a3a7
chore(test_stand): add more urls for traffic-gen
baydakov-georgiy 8fdb3ed
feat(test_stand): add interaction with controller and worker
baydakov-georgiy 9e90f1d
docs(test_stand): instruction for using test stand
baydakov-georgiy d4a83e7
feat(test_stand): add autostart in vm for controller and worker
baydakov-georgiy 75c99db
feat(test_stand): add IPv6 support
baydakov-georgiy 3837050
feat(test_stand): add grafana and prometheus for metrics
baydakov-georgiy 2852c75
docs: update wiki-using_test_stand
LapshinAE0 c3a79b3
docs: fix api python commands
LapshinAE0 a0c11f9
feat(test_stand): add DHCP server
baydakov-georgiy d61c2fc
feat(test_stand): add redis-server for controller cash
baydakov-georgiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,34 @@ | ||
| NUM_HOSTS=3 | ||
| SUBNET=10.0.0 | ||
| GATEWAY=10.0.0.254 | ||
| NUM_HOSTS_NET1=2 | ||
| NUM_HOSTS_NET2=2 | ||
|
|
||
| SUBNET1=10.0.0 | ||
| SUBNET2=10.0.1 | ||
| GATEWAY1=10.0.0.254 | ||
| GATEWAY2=10.0.1.254 | ||
| BRIDGE1=br-testnet1 | ||
| BRIDGE2=br-testnet2 | ||
| DNS=8.8.8.8 | ||
| FILTER_PATH=../../worker/main-x86-virt | ||
| BRIDGE_IFACE=br-testnet | ||
|
|
||
| SUBNET1_V6=fd00:1:: | ||
| SUBNET2_V6=fd00:2:: | ||
| DNS_V6=2001:4860:4860::8888 | ||
|
|
||
| INET_SUBNET=10.0.3 | ||
| INET_BRIDGE=br-inet | ||
| INET_SUBNET_V6=fd00:b:: | ||
|
|
||
| MGMT_SUBNET=10.0.2 | ||
| MGMT_BRIDGE=br-mgmt | ||
| MGMT_SUBNET_V6=fd00:a:: | ||
|
|
||
| YOCTO_DEPLOY_DIR=/home/lespend/program/yadro/vm_build_risc_v/qemu/poky/build/tmp/deploy/images/qemuriscv64 | ||
| QEMU_ROOTFS=${YOCTO_DEPLOY_DIR}/cluster-image-qemuriscv64.rootfs.ext4 | ||
| QEMU_KERNEL=${YOCTO_DEPLOY_DIR}/Image | ||
| QEMU_BIOS=${YOCTO_DEPLOY_DIR}/fw_jump.elf | ||
| QEMU_MEMORY=4G | ||
| QEMU_CPUS=2 | ||
|
|
||
| FILTER_RISCV_BIN=../../worker/main-riscv | ||
| CONTROLLER_BIN=../../controller/bazel-bin/cmd/grpc_server/grpc_server_/grpc_server | ||
|
|
||
| HUGEPAGES=1024 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| SCRIPTS_DIR = scripts | ||
| WORKER_DIR = ../../worker | ||
| CONTROLLER_DIR = ../../controller | ||
|
|
||
| .PHONY: run stop logs build build-worker build-controller clean-vms | ||
|
|
||
| run: build | ||
| sudo $(SCRIPTS_DIR)/start.sh | ||
|
|
||
| stop: | ||
| sudo $(SCRIPTS_DIR)/stop.sh | ||
|
|
||
| logs: | ||
| @sudo bash -c 'while true; do clear; cat shared/filter1.log 2>/dev/null | tail -10; echo "---"; cat shared/filter2.log 2>/dev/null | tail -10; echo "---"; cat shared/controller.log 2>/dev/null | tail -5; sleep 2; done' | ||
|
|
||
| build: build-worker build-controller | ||
|
|
||
| build-worker: | ||
| cd $(WORKER_DIR) && bazel build --config=riscv64 //:worker | ||
|
|
||
| build-controller: | ||
| $(MAKE) -C $(CONTROLLER_DIR) build-riscv | ||
|
|
||
| clean-vms: | ||
| rm -f filter1.qcow2 filter2.qcow2 controller.qcow2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,50 +1,74 @@ | ||
| # Тестовый стенд виртуальной нагрузки | ||
| # Виртуальный тестовый стенд | ||
|
|
||
| ## Установка | ||
| ## Что необходимо сделать | ||
| - [x] Настроить топологию сети и виртуальные машины | ||
| - [x] Добавить кросс-компиляцию controller под RISC-V | ||
| - [x] Добaвить кросс-компиляцию dpdk библиотеки | ||
| - [x] На данный момент используется Docker контейнер внутри которого билдиться библиотека. Это медленно (минут 50, но делается один раз) | ||
| - [ ] (\*) По хорошему необходимо создать отдельный sysroot с помощью Yocto Project внутри которого будем билдить | ||
| - [x] Запуск фильтров и контроллера | ||
| - [x] Запуск фильтров происходит через ssh подключение и прописывание вручную комманды | ||
| - [ ] (\*) По хорошему необходимо сделать запуск через systemd | ||
| - [ ] Взаимодействие controller и worker, пока не сделано: | ||
| - [ ] Кросс компиляция worker вместе с dpdk-filter. На данный момент билдиться только сам dpdk-filter | ||
|
|
||
| ### DPDK | ||
| ```sh | ||
| sudo apt-get install -y meson ninja-build python3-pyelftools libbpf-dev | ||
| git clone https://github.com/DPDK/dpdk.git | ||
| cd dpdk | ||
| meson setup -Denable_drivers=net/af_xdp,net/tap build | ||
| ninja -C build | ||
| sudo ninja -C build install | ||
| ``` | ||
| ## Подготовка | ||
|
|
||
| ### Компиляция worker | ||
| ### Создание RISC-V образа | ||
| ```sh | ||
| cd worker | ||
| make -f Makefile.main_x86 virt | ||
| sudo scripts/create_image.sh | ||
| ``` | ||
|
|
||
| Пока скрипт из test-image переписан только под arch linux. Надо переписать его под ubuntu и запускать внутри docker контейнера | ||
|
|
||
| Подробности: `wiki/using_test_image.md` | ||
|
|
||
| ## Конфигурация | ||
|
|
||
| Параметры задаются в `.env`: | ||
| Параметры в `.env`: | ||
|
|
||
| | Переменная | По умолчанию | Описание | | ||
| |---------------|---------------------------|----------------------------------| | ||
| | NUM_HOSTS | 3 | Количество генераторов трафика | | ||
| | SUBNET | 10.0.0 | Подсеть (первые 3 октета) | | ||
| | GATEWAY | 10.0.0.254 | Адрес шлюза | | ||
| | DNS | 8.8.8.8 | DNS для контейнеров | | ||
| | FILTER_PATH | ../../worker/main-x86-virt| Путь до бинаря фильтра | | ||
| | HUGEPAGES | 1024 | Количество hugepages | | ||
| | Переменная | По умолчанию | Описание | | ||
| |------------------|----------------------|-----------------------------------| | ||
| | NUM_HOSTS_NET1 | 2 | Генераторов в сети 1 | | ||
| | NUM_HOSTS_NET2 | 2 | Генераторов в сети 2 | | ||
| | SUBNET1 | 10.0.0 | Подсеть 1 | | ||
| | SUBNET2 | 10.0.1 | Подсеть 2 | | ||
| | MGMT_SUBNET | 10.0.2 | Управляющая подсеть | | ||
| | QEMU_IMAGE | ubuntu-...riscv64.img| Путь к RISC-V образу | | ||
| | QEMU_MEMORY | 4G | RAM на каждую VM | | ||
| | QEMU_CPUS | 2 | CPU на каждую VM | | ||
| | FILTER_RISCV_BIN | ../../worker/main-riscv-virt | Путь к бинарю фильтра | | ||
| | CONTROLLER_BIN | ../../controller/bin/grpc_server | Путь к контроллеру | | ||
| | HUGEPAGES | 1024 | Количество hugepages | | ||
|
|
||
| ## Запуск | ||
|
|
||
| Виртуальные машины и сеть: | ||
| ```sh | ||
| cd test/virtual_load_network | ||
| sudo scripts/start.sh | ||
| make run | ||
| ``` | ||
|
|
||
| Запуск фильтров осуществляется через подлкючение по ssh: | ||
| ``` | ||
| # for filter1 | ||
| ssh-keygen -R 10.0.2.1 | ||
| ssh ubuntu@10.0.2.1 | ||
| # password ubuntu | ||
| # in VM: | ||
| sudo rm -rf /var/run/dpdk /dev/hugepages/rtemap_* | ||
| sudo LIBXDP_OBJECT_PATH=/usr/lib/riscv64-linux-gnu/bpf LD_LIBRARY_PATH=/mnt/lib /mnt/filter --no-pci --iova-mode=va -d /mnt/lib/librte_net_af_xdp.so -d /mnt/lib/librte_net_tap.so -- | ||
|
|
||
| Скрипт выполняет: | ||
| 1. Настройку hugepages | ||
| 2. Запуск контейнеров-генераторов через `docker compose` | ||
| 3. Создание veth пары и tc mirroring на bridge compose-сети | ||
| 4. Настройку NAT | ||
| 5. Запуск DPDK фильтра | ||
| # Also for filter2 | ||
| ssh-keygen -R 10.0.2.2 | ||
| ssh ubuntu@10.0.2.2 | ||
| # password ubuntu | ||
| # in VM: | ||
| sudo rm -rf /var/run/dpdk /dev/hugepages/rtemap_* | ||
| sudo LIBXDP_OBJECT_PATH=/usr/lib/riscv64-linux-gnu/bpf LD_LIBRARY_PATH=/mnt/lib /mnt/filter --no-pci --iova-mode=va -d /mnt/lib/librte_net_af_xdp.so -d /mnt/lib/librte_net_tap.so -- | ||
| ``` | ||
|
|
||
| ## Остановка | ||
| ```sh | ||
| sudo scripts/stop.sh | ||
| make stop | ||
| ``` |
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Опять ключ попал в код |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| KASPERSKY_API_KEY=wyo915OXTCe5stpLCtc5Ww== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [global.rules] | ||
| block_categories = ["adult", "malware"] | ||
| block_domains = ["example.com", "blocked-site.com"] | ||
| allow_domains = ["google.com", "github.com"] | ||
| min_trust_level = 50 | ||
|
|
||
| [global.rules.block_by_trust] | ||
| dangerous = 10 | ||
| suspicious = 30 | ||
|
|
||
| [filters.filter_1] | ||
| block_domains = ["extra-blocked.com"] | ||
|
|
||
| [filters.filter_2] | ||
| allow_domains = ["extra-allowed.com"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| CONTROLLER_GRPC_ADDR=10.0.2.3:50051 | ||
| METRICS_GATEWAY_ADDRESS=10.0.2.254 | ||
| METRICS_GATEWAY_PORT=9091 | ||
| DPDK_PORT_IN=eth0 | ||
| DPDK_PORT_OUT=eth1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,90 @@ | ||
| services: | ||
| traffic-gen: | ||
| traffic-gen-1: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.traffic-gen | ||
| networks: | ||
| - testnet | ||
| - testnet1 | ||
| cap_add: | ||
| - NET_ADMIN | ||
| dns: | ||
| - ${DNS:-8.8.8.8} | ||
| - ${DNS_V6:-2001:4860:4860::8888} | ||
| deploy: | ||
| replicas: ${NUM_HOSTS:-3} | ||
| replicas: ${NUM_HOSTS_NET1:-2} | ||
| restart: unless-stopped | ||
|
|
||
| traffic-gen-2: | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile.traffic-gen | ||
| networks: | ||
| - testnet2 | ||
| cap_add: | ||
| - NET_ADMIN | ||
| dns: | ||
| - ${DNS:-8.8.8.8} | ||
| - ${DNS_V6:-2001:4860:4860::8888} | ||
| deploy: | ||
| replicas: ${NUM_HOSTS_NET2:-2} | ||
| restart: unless-stopped | ||
|
|
||
| pushgateway: | ||
| image: prom/pushgateway:latest | ||
| ports: | ||
| - "9091:9091" | ||
| restart: unless-stopped | ||
|
|
||
| prometheus: | ||
| image: prom/prometheus:latest | ||
| volumes: | ||
| - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro | ||
| ports: | ||
| - "9090:9090" | ||
| depends_on: | ||
| - pushgateway | ||
| restart: unless-stopped | ||
|
|
||
| grafana: | ||
| image: grafana/grafana:latest | ||
| volumes: | ||
| - ./monitoring/grafana/provisioning:/etc/grafana/provisioning:ro | ||
| - grafana-data:/var/lib/grafana | ||
| ports: | ||
| - "3000:3000" | ||
| environment: | ||
| GF_AUTH_ANONYMOUS_ENABLED: "true" | ||
| GF_AUTH_ANONYMOUS_ORG_ROLE: "Admin" | ||
| depends_on: | ||
| - prometheus | ||
| restart: unless-stopped | ||
|
|
||
| networks: | ||
| testnet: | ||
| testnet1: | ||
| driver: bridge | ||
| enable_ipv6: true | ||
| driver_opts: | ||
| com.docker.network.bridge.name: "br-testnet1" | ||
| com.docker.network.bridge.enable_ip_masquerade: "false" | ||
| ipam: | ||
| config: | ||
| - subnet: ${SUBNET1:-10.0.0}.0/24 | ||
| gateway: ${SUBNET1:-10.0.0}.254 | ||
| - subnet: ${SUBNET1_V6:-fd00:1::}0/64 | ||
| gateway: ${SUBNET1_V6:-fd00:1::}ff | ||
|
|
||
| testnet2: | ||
| driver: bridge | ||
| enable_ipv6: true | ||
| driver_opts: | ||
| com.docker.network.bridge.name: "br-testnet" | ||
| com.docker.network.bridge.name: "br-testnet2" | ||
| com.docker.network.bridge.enable_ip_masquerade: "false" | ||
| ipam: | ||
| config: | ||
| - subnet: ${SUBNET:-10.0.0}.0/24 | ||
| gateway: ${GATEWAY:-10.0.0.254} | ||
| - subnet: ${SUBNET2:-10.0.1}.0/24 | ||
| gateway: ${SUBNET2:-10.0.1}.254 | ||
| - subnet: ${SUBNET2_V6:-fd00:2::}0/64 | ||
| gateway: ${SUBNET2_V6:-fd00:2::}ff | ||
|
|
||
| volumes: | ||
| grafana-data: |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Очевидно не хватает зависимостей по файлам