Skip to content

Commit

Permalink
test: E2E download concurrency (dragonflyoss#467)
Browse files Browse the repository at this point in the history
* test: E2E download concurrency

Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Jul 19, 2021
1 parent a5e9510 commit 9af0bab
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 48 deletions.
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/google/uuid v1.1.5
github.com/gorilla/mux v1.7.3
github.com/jarcoal/httpmock v1.0.8
github.com/klauspost/compress v1.13.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
Expand Down Expand Up @@ -55,8 +56,9 @@ require (
go.uber.org/atomic v1.6.0
go.uber.org/zap v1.16.0
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
golang.org/x/time v0.0.0-20201208040808-7e3f01d25324
golang.org/x/tools v0.1.4 // indirect
gonum.org/v1/gonum v0.9.3
Expand Down
9 changes: 6 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.12.2 h1:2KCfW3I9M7nSc5wOqXAlW2v2U6v+w6cbjvbfp+OykW8=
github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/klauspost/compress v1.13.1 h1:wXr2uRxZTJXHLly6qhJabee5JqIhTRoLBhDOA74hDEQ=
github.com/klauspost/compress v1.13.1/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
Expand Down Expand Up @@ -683,8 +684,9 @@ golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201202161906-c7110b5ffcbb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781 h1:DzZ89McO9/gWPsQXS/FVKAlG02ZjaQ6AlZRBimEYOd0=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -738,8 +740,9 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22 h1:RqytpXGR1iVNX7psjB3ff8y7sNFinVFvkx1c8SjBkio=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b h1:9zKuko04nR4gjZ4+DNjHqRlAJqbJETHwiNKDqTfOjfE=
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
41 changes: 36 additions & 5 deletions hack/install-e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ set -o errexit
set -o pipefail

KIND_CONFIG_PATH="test/testdata/kind/config.yaml"
NAMESPACE="dragonfly-system"
CHARTS_CONFIG_PATH="test/testdata/charts/config.yaml"
FILE_SERVER_CONFIG_PATH="test/testdata/k8s/file-server.yaml"
CHARTS_PATH="deploy/charts/dragonfly"
NAMESPACE="dragonfly-system"
E2E_NAMESPACE="dragonfly-e2e"
FILE_SERVER_NAME="file-server-0"
curDir=$(cd "$(dirname "$0")" && pwd)
cd "${curDir}/../" || return

Expand All @@ -29,18 +33,33 @@ install-helm() {
curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | sh
fi

helm install --wait --timeout 10m --create-namespace --namespace ${NAMESPACE} dragonfly ${CHARTS_PATH}
helm install --wait --timeout 10m --create-namespace --namespace ${NAMESPACE} -f ${CHARTS_CONFIG_PATH} dragonfly ${CHARTS_PATH}
}

install-file-server() {
kubectl apply -f ${FILE_SERVER_CONFIG_PATH}
kubectl wait --namespace ${E2E_NAMESPACE} \
--for=condition=ready pod ${FILE_SERVER_NAME} \
--timeout=10m
}

install-ginkgo() {
if which ginkgo >/dev/null ; then
print_step_info "ginkgo has been installed"
else
print_step_info "start install ginkgo"
go get github.com/onsi/ginkgo/ginkgo
fi
}

install-apache-bench() {
if which ab >/dev/null ; then
print_step_info "apache bench has been installed"
else
apt-get update
apt-get install apache2-utils
fi
}

install-local() {
print_step_info "start kind create cluster"
install-kind
Expand All @@ -54,8 +73,14 @@ install-local() {
print_step_info "start helm install dragonfly"
install-helm

print_step_info "start ginkgo install dragonfly"
print_step_info "start install file server"
install-file-server

print_step_info "start install ginkgo"
install-ginkgo

print_step_info "start install apache bench"
install-apache-bench
}

install-actions() {
Expand All @@ -68,8 +93,14 @@ install-actions() {
print_step_info "start helm install dragonfly"
install-helm

print_step_info "start ginkgo install dragonfly"
print_step_info "start install file server"
install-file-server

print_step_info "start install ginkgo"
install-ginkgo

print_step_info "start install apache bench"
install-apache-bench
}

print_step_info() {
Expand Down
70 changes: 70 additions & 0 deletions test/e2e/concurrency_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* Copyright 2020 The Dragonfly Authors
*
* Licensed 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.
*/

package e2e

import (
"fmt"

"d7y.io/dragonfly/v2/test/e2e/e2eutil"
. "github.com/onsi/ginkgo" //nolint
. "github.com/onsi/gomega" //nolint
)

const (
hostnameFilePath = "/etc/hostname"
proxy = "localhost:65001"
)

var _ = Describe("Download concurrency", func() {
Context("ab", func() {
It("concurrent 100 should be ok", func() {
url := e2eutil.GetFileURL(hostnameFilePath)
fmt.Println("download url " + url)

out, err := e2eutil.ABCommand("-c", "100", "-n", "200", "-X", proxy, url).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())
})

It("concurrent 200 should be ok", func() {
url := e2eutil.GetFileURL(hostnameFilePath)
fmt.Println("download url " + url)

out, err := e2eutil.ABCommand("-c", "200", "-n", "400", "-X", proxy, url).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())
})

It("concurrent 500 should be ok", func() {
url := e2eutil.GetFileURL(hostnameFilePath)
fmt.Println("download url " + url)

out, err := e2eutil.ABCommand("-c", "500", "-n", "1000", "-X", proxy, url).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())
})

It("concurrent 1000 should be ok", func() {
url := e2eutil.GetFileURL(hostnameFilePath)
fmt.Println("download url " + url)

out, err := e2eutil.ABCommand("-c", "1000", "-n", "2000", "-X", proxy, url).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())
})
})
})
38 changes: 4 additions & 34 deletions test/e2e/dfget_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,11 @@ import (
)

const (
dragonflyNamespace = "dragonfly-system"
dragonflyE2ENamespace = "dragonfly-e2e"
dragonflyNamespace = "dragonfly-system"
)

var _ = Describe("Download with dfget", func() {
Context("dfget", func() {
It("setup file server should be ok", func() {
// create file server
out, err := e2eutil.KubeCtlCommand("apply", "-f", "../testdata/k8s/file-server.yaml").CombinedOutput()
Expect(err).NotTo(HaveOccurred())
fmt.Println(string(out))

// wait file server ready
out, err = e2eutil.KubeCtlCommand("-n", dragonflyE2ENamespace,
"wait", "--for=condition=ready", "--timeout=5m", "pod", "file-server-0").CombinedOutput()
Expect(err).NotTo(HaveOccurred())
fmt.Println(string(out))
})

It("dfget download should be ok", func() {
out, err := e2eutil.KubeCtlCommand("-n", dragonflyNamespace, "get", "pod", "-l", "component=dfdaemon",
"-o", "jsonpath='{range .items[*]}{.metadata.name}{end}'").CombinedOutput()
Expand All @@ -54,28 +40,12 @@ var _ = Describe("Download with dfget", func() {
Expect(strings.HasPrefix(podName, "dragonfly-dfdaemon-")).Should(BeTrue())
pod := e2eutil.NewPodExec(dragonflyNamespace, podName)

files := []string{
"/etc/containerd/config.toml",
"/etc/fstab",
"/etc/hostname",
"/usr/bin/kubectl",
"/usr/bin/systemctl",
"/usr/local/bin/containerd-shim",
"/usr/local/bin/clean-install",
"/usr/local/bin/entrypoint",
"/usr/local/bin/containerd-shim-runc-v2",
"/usr/local/bin/ctr",
"/usr/local/bin/containerd",
"/usr/local/bin/create-kubelet-cgroup-v2",
"/usr/local/bin/crictl",
"/usr/local/bin/containerd-fuse-overlayfs-grpc",
}
for i := range files {
url := fmt.Sprintf("http://file-server.dragonfly-e2e.svc/kind%s", files[i])
for _, v := range e2eutil.GetFileList() {
url := e2eutil.GetFileURL(v)
fmt.Println("download url " + url)

// get original file digest
out, err = e2eutil.DockerCommand("sha256sum", files[i]).CombinedOutput()
out, err = e2eutil.DockerCommand("sha256sum", v).CombinedOutput()
fmt.Println(string(out))
Expect(err).NotTo(HaveOccurred())
sha256sum1 := strings.Split(string(out), " ")[0]
Expand Down
8 changes: 7 additions & 1 deletion test/e2e/e2eutil/exec.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package e2eutil

import "os/exec"
import (
"os/exec"
)

const (
kindDockerContainer = "kind-control-plane"
Expand All @@ -22,6 +24,10 @@ func KubeCtlCommand(arg ...string) *exec.Cmd {
return exec.Command("kubectl", arg...)
}

func ABCommand(arg ...string) *exec.Cmd {
return exec.Command("ab", arg...)
}

type PodExec struct {
namespace string
name string
Expand Down
26 changes: 26 additions & 0 deletions test/e2e/e2eutil/file_server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package e2eutil

import "fmt"

func GetFileList() []string {
return []string{
"/etc/containerd/config.toml",
"/etc/fstab",
"/etc/hostname",
"/usr/bin/kubectl",
"/usr/bin/systemctl",
"/usr/local/bin/containerd-shim",
"/usr/local/bin/clean-install",
"/usr/local/bin/entrypoint",
"/usr/local/bin/containerd-shim-runc-v2",
"/usr/local/bin/ctr",
"/usr/local/bin/containerd",
"/usr/local/bin/create-kubelet-cgroup-v2",
"/usr/local/bin/crictl",
}
}

func GetFileURL(filePath string) string {
baseURL := "http://file-server.dragonfly-e2e.svc/kind"
return fmt.Sprintf("%s%s", baseURL, filePath)
}
Loading

0 comments on commit 9af0bab

Please sign in to comment.