Skip to content
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

smoke: support more images #1504

Merged
merged 2 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ jobs:
tag: 6.1.1
- image: node
tag: 19.8
- image: python
tag: 3.10.7
- image: golang
tag: 1.19.3
- image: ruby
tag: 3.1.3
- image: amazoncorretto
tag: 8-al2022-jdk
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -113,6 +121,14 @@ jobs:
tag: 6.1.1
- image: node
tag: 19.8
- image: python
tag: 3.10.7
- image: golang
tag: 1.19.3
- image: ruby
tag: 3.1.3
- image: amazoncorretto
tag: 8-al2022-jdk
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -151,6 +167,14 @@ jobs:
tag: 6.1.1
- image: node
tag: 19.8
- image: python
tag: 3.10.7
- image: golang
tag: 1.19.3
- image: ruby
tag: 3.1.3
- image: amazoncorretto
tag: 8-al2022-jdk
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -189,6 +213,14 @@ jobs:
tag: 6.1.1
- image: node
tag: 19.8
- image: python
tag: 3.10.7
- image: golang
tag: 1.19.3
- image: ruby
tag: 3.1.3
- image: amazoncorretto
tag: 8-al2022-jdk
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -216,9 +248,21 @@ jobs:
"wordpress")
echo "### workload: wait the 80 port response" > $GITHUB_STEP_SUMMARY
;;
"node")
"node")
echo "### workload: node index.js; wait the 80 port response" > $GITHUB_STEP_SUMMARY
;;
"python")
echo "### workload: python -c 'print("hello")'" > $GITHUB_STEP_SUMMARY
;;
"golang")
echo "### workload: go run main.go" > $GITHUB_STEP_SUMMARY
;;
"ruby")
echo "### workload: ruby -e "puts \"hello\""" > $GITHUB_STEP_SUMMARY
;;
"amazoncorretto")
echo "### workload: javac Main.java; java Main" > $GITHUB_STEP_SUMMARY
;;
esac
cd benchmark-result
metric_files=(
Expand Down
2 changes: 2 additions & 0 deletions smoke/tests/texture/golang/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
cd /src
go run main.go
7 changes: 7 additions & 0 deletions smoke/tests/texture/golang/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("hello")
}
5 changes: 5 additions & 0 deletions smoke/tests/texture/java/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Main {
public static void main(String[] args) {
System.out.println("hello");
}
}
3 changes: 3 additions & 0 deletions smoke/tests/texture/java/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cd /src
javac Main.java
java Main
1 change: 1 addition & 0 deletions smoke/tests/texture/python/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python -c 'print("hello")'
1 change: 1 addition & 0 deletions smoke/tests/texture/ruby/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ruby -e "puts \"hello\""
51 changes: 48 additions & 3 deletions smoke/tests/tool/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,41 @@ var URL_WAIT = map[string]RunArgs{
},
}

var CMD_STDOUT = map[string]RunArgs{
"golang": {
Mount: mountPath{
source: "tests/texture/golang",
target: "/src",
},
},
"amazoncorretto": {
Mount: mountPath{
source: "tests/texture/java",
target: "/src",
},
},
"ruby": {
Mount: mountPath{
source: "tests/texture/ruby",
target: "/src",
},
},
"python": {
Mount: mountPath{
source: "tests/texture/python",
target: "/src",
},
},
}

// SupportContainerImage help to check if we support the image or not
func SupportContainerImage(image string) bool {
_, ok := URL_WAIT[image]
return ok
_, existsInUrlWait := URL_WAIT[image]
_, existsInCmdStdout := CMD_STDOUT[image]
return existsInUrlWait || existsInCmdStdout
}

// runUrlWaitContainer run Contaienr util geting http response from WaitUrl
// runUrlWaitContainer run container util geting http response from WaitUrl
func runUrlWaitContainer(t *testing.T, image string, containerName string, runArgs RunArgs) {
cmd := "sudo nerdctl --insecure-registry --snapshotter nydus run -d --net=host"
if runArgs.Mount.source != "" {
Expand All @@ -91,6 +119,20 @@ func runUrlWaitContainer(t *testing.T, image string, containerName string, runAr
}
}

// runCmdStdoutContainer run some commands in container by entrypoint.sh
func runCmdStdoutContainer(t *testing.T, image string, containerName string, runArgs RunArgs) {
cmd := "sudo nerdctl --insecure-registry --snapshotter nydus run -i --net=host"
if runArgs.Mount.source != "" {
currentDir, err := os.Getwd()
if err != nil {
t.Fatalf("can't get rooted path name")
}
cmd += fmt.Sprintf(" -v %s:%s", filepath.Join(currentDir, runArgs.Mount.source), runArgs.Mount.target)
}
cmd += fmt.Sprintf(" --name=%s %s sh /src/entrypoint.sh", containerName, image)
Run(t, cmd)
}

// RunContainerWithBaseline and get metrics from api socket.
// Test will fail if performance below baseline.
func RunContainerWithBaseline(t *testing.T, image string, containerName string, mode string) {
Expand Down Expand Up @@ -122,6 +164,9 @@ func RunContainer(t *testing.T, image string, containerName string) *ContainerMe
if ok {
runUrlWaitContainer(t, image, containerName, args)
defer clearContainer(t, image, containerName)
} else if args, ok := CMD_STDOUT[ImageRepo(t, image)]; ok {
runCmdStdoutContainer(t, image, containerName, args)
defer clearContainer(t, image, containerName)
}

containerMetic.E2ETime = time.Since(startTime)
Expand Down