Skip to content

Commit

Permalink
Add iperf tests to smoketest. Fixes #1158
Browse files Browse the repository at this point in the history
  • Loading branch information
plorenz committed Jun 23, 2023
1 parent a351822 commit 02b979c
Show file tree
Hide file tree
Showing 14 changed files with 364 additions and 94 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
- name: Test Ziti Command
run: |
echo "ZITI_ROOT=$(go env GOPATH)/bin" >> "$GITHUB_ENV"
pushd zititest && go test -v ./tests/... && popd
pushd zititest && go test -timeout 30m -v ./tests/... && popd
- name: Test Ziti Command Teardown
if: always()
Expand Down
2 changes: 1 addition & 1 deletion zititest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/michaelquigley/pfxlog v0.6.10
github.com/openziti/channel/v2 v2.0.81
github.com/openziti/edge v0.24.348
github.com/openziti/fablab v0.4.58-0.20230614203155-19a2a4d811d3
github.com/openziti/fablab v0.5.0
github.com/openziti/fabric v0.23.39
github.com/openziti/foundation/v2 v2.0.26
github.com/openziti/identity v1.0.57
Expand Down
6 changes: 2 additions & 4 deletions zititest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -647,10 +647,8 @@ github.com/openziti/edge v0.24.348 h1:m0zh1n5OBj7Tjemu9XfxdYhbKvo6HdGQMHfC/Zledb
github.com/openziti/edge v0.24.348/go.mod h1:wcoBVKqW99/CBg7LjzbHT3dJ8JMlRZelPhbjNcjwMr0=
github.com/openziti/edge-api v0.25.29 h1:DbZ0GKpch9ik+XnC0qoP1dOg1AmgUEeWH4VIyOIehrQ=
github.com/openziti/edge-api v0.25.29/go.mod h1:mqYquh1RYvHjV/M9MGO4Ng0Xq9ixAH8o8cT5kw5XCWY=
github.com/openziti/fablab v0.4.52 h1:X5+NaRnfPxbzhxUh9b4IQmVNVgYWFf8/Ck2sKNz77ho=
github.com/openziti/fablab v0.4.52/go.mod h1:aF8Fu3C8hnnaOJyAZz3AXGY4cMxQyBLhoIlSRJ/VVpc=
github.com/openziti/fablab v0.4.58-0.20230614203155-19a2a4d811d3 h1:Bkiiz5vi0GFezbuNBq21Dgp4oMkSeaPruF6/RlSAcZE=
github.com/openziti/fablab v0.4.58-0.20230614203155-19a2a4d811d3/go.mod h1:6T8sAnRdko8ozxS4pZWCM9rNuGr/fkB7G93N41utpl0=
github.com/openziti/fablab v0.5.0 h1:+CMVE08hS62UR3tIfEvMb3XcWwzD1np//cpHHTboVW8=
github.com/openziti/fablab v0.5.0/go.mod h1:VLvs0AAuKAFqy8jhGvs+FgszYEbB456duPOBfRj4peU=
github.com/openziti/fabric v0.23.39 h1:t6npkfBsPr+8GvF9X/rTLHxGsce5FTa4NoA80MInxYc=
github.com/openziti/fabric v0.23.39/go.mod h1:px2zUzQrgObmv6sdXgGJ028Wr45aGcgpFvfIP/qgDFo=
github.com/openziti/foundation/v2 v2.0.26 h1:RISGM97aIFnnEkxrcVsO6fnGg9W4ByydSnqWAVkJAqY=
Expand Down
93 changes: 45 additions & 48 deletions zititest/models/simple/actions/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package actions

import (
"fmt"
"github.com/openziti/ziti/zititest/zitilab"
"time"

Expand All @@ -41,7 +42,7 @@ func (a *bootstrapAction) bind(m *model.Model) model.Action {

workflow.AddAction(host.GroupExec("*", 25, "rm -f logs/*"))
workflow.AddAction(component.Stop("#ctrl"))
workflow.AddAction(component.Exec("#ctrl", (*zitilab.ControllerType).InitStandalone))
workflow.AddAction(component.Exec("#ctrl", zitilab.ControllerActionInitStandalone))
workflow.AddAction(component.Start("#ctrl"))
workflow.AddAction(edge.ControllerAvailable("#ctrl", 30*time.Second))

Expand All @@ -68,56 +69,52 @@ func (a *bootstrapAction) bind(m *model.Model) model.Action {
"protocol" : "tcp"
}`))

workflow.AddAction(zitilib_actions.Edge("create", "config", "files-intercept-ert-unencrypted", "intercept.v1", `
workflow.AddAction(zitilib_actions.Edge("create", "config", "iperf-host", "host.v1", `
{
"addresses": ["ziti-files-ert-unencrypted.s3-us-west-1.amazonaws.ziti"],
"portRanges" : [ { "low": 443, "high": 443 } ],
"protocols": ["tcp"]
}`))

workflow.AddAction(zitilib_actions.Edge("create", "config", "files-intercept-ert", "intercept.v1", `
{
"addresses": ["ziti-files-ert.s3-us-west-1.amazonaws.ziti"],
"portRanges" : [ { "low": 443, "high": 443 } ],
"protocols": ["tcp"]
}`))

workflow.AddAction(zitilib_actions.Edge("create", "config", "files-intercept-zet-unencrypted", "intercept.v1", `
{
"addresses": ["ziti-files-zet-unencrypted.s3-us-west-1.amazonaws.ziti"],
"portRanges" : [ { "low": 443, "high": 443 } ],
"protocols": ["tcp"]
}`))

workflow.AddAction(zitilib_actions.Edge("create", "config", "files-intercept-zet", "intercept.v1", `
{
"addresses": ["ziti-files-zet.s3-us-west-1.amazonaws.ziti"],
"portRanges" : [ { "low": 443, "high": 443 } ],
"protocols": ["tcp"]
}`))

workflow.AddAction(zitilib_actions.Edge("create", "config", "files-intercept-ziti-tunnel-unencrypted", "intercept.v1", `
{
"addresses": ["ziti-files-ziti-tunnel-unencrypted.s3-us-west-1.amazonaws.ziti"],
"portRanges" : [ { "low": 443, "high": 443 } ],
"protocols": ["tcp"]
}`))

workflow.AddAction(zitilib_actions.Edge("create", "config", "files-intercept-ziti-tunnel", "intercept.v1", `
{
"addresses": ["ziti-files-ziti-tunnel.s3-us-west-1.amazonaws.ziti"],
"portRanges" : [ { "low": 443, "high": 443 } ],
"protocols": ["tcp"]
"address" : "localhost",
"port" : 5201,
"protocol" : "tcp"
}`))

workflow.AddAction(zitilib_actions.Edge("create", "service", "ert-files-unencrypted", "-c", "files-host,files-intercept-ert-unencrypted", "-e", "OFF", "-a", "ert"))
workflow.AddAction(zitilib_actions.Edge("create", "service", "ert-files", "-c", "files-host,files-intercept-ert", "-a", "ert"))

workflow.AddAction(zitilib_actions.Edge("create", "service", "zet-files-unencrypted", "-c", "files-host,files-intercept-zet-unencrypted", "-e", "OFF", "-a", "zet"))
workflow.AddAction(zitilib_actions.Edge("create", "service", "zet-files", "-c", "files-host,files-intercept-zet", "-a", "zet"))

workflow.AddAction(zitilib_actions.Edge("create", "service", "ziti-tunnel-files-unencrypted", "-c", "files-host,files-intercept-ziti-tunnel-unencrypted", "-e", "OFF", "-a", "ziti-tunnel"))
workflow.AddAction(zitilib_actions.Edge("create", "service", "ziti-tunnel-files", "-c", "files-host,files-intercept-ziti-tunnel", "-a", "ziti-tunnel"))
for _, encrypted := range []bool{false, true} {
for _, hostType := range []string{"ert", "zet", "ziti-tunnel"} {
suffix := ""
encryptionFlag := "ON"

if !encrypted {
suffix = "-unencrypted"
encryptionFlag = "OFF"
}

filesConfigName := fmt.Sprintf("files-intercept-%s%s", hostType, suffix)
filesConfigDef := fmt.Sprintf(`
{
"addresses": ["files-%s%s.s3-us-west-1.amazonaws.ziti"],
"portRanges" : [ { "low": 443, "high": 443 } ],
"protocols": ["tcp"]
}`, hostType, suffix)

workflow.AddAction(zitilib_actions.Edge("create", "config", filesConfigName, "intercept.v1", filesConfigDef))

iperfConfigName := fmt.Sprintf("iperf-intercept-%s%s", hostType, suffix)
iperfConfigDef := fmt.Sprintf(`
{
"addresses": ["iperf-%s%s.ziti"],
"portRanges" : [ { "low": 5201, "high": 5201 } ],
"protocols": ["tcp"]
}`, hostType, suffix)

workflow.AddAction(zitilib_actions.Edge("create", "config", iperfConfigName, "intercept.v1", iperfConfigDef))

filesServiceName := fmt.Sprintf("%s-files%s", hostType, suffix)
filesConfigs := fmt.Sprintf("files-host,%s", filesConfigName)
workflow.AddAction(zitilib_actions.Edge("create", "service", filesServiceName, "-c", filesConfigs, "-e", encryptionFlag, "-a", hostType))

iperfServiceName := fmt.Sprintf("%s-iperf%s", hostType, suffix)
iperfConfigs := fmt.Sprintf("iperf-host,%s", iperfConfigName)
workflow.AddAction(zitilib_actions.Edge("create", "service", iperfServiceName, "-c", iperfConfigs, "-e", encryptionFlag, "-a", hostType))
}
}

workflow.AddAction(zitilib_actions.Edge("create", "service-policy", "ert-hosts", "Bind", "--service-roles", "#ert", "--identity-roles", "#ert-host"))
workflow.AddAction(zitilib_actions.Edge("create", "service-policy", "zet-hosts", "Bind", "--service-roles", "#zet", "--identity-roles", "#zet-host"))
Expand Down
5 changes: 5 additions & 0 deletions zititest/models/simple/actions/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,18 @@ func (a *startAction) bind(m *model.Model) model.Action {
workflow.AddAction(component.Start("#ctrl"))
workflow.AddAction(edge.ControllerAvailable("#ctrl", 30*time.Second))
workflow.AddAction(component.StartInParallel(models.EdgeRouterTag, 25))
workflow.AddAction(component.StartInParallel(".iperf", 5))

workflow.AddAction(semaphore.Sleep(2 * time.Second))
workflow.AddAction(zitilib_actions.StartMetricbeat("*", a.Metricbeat.ConfigPath, a.Metricbeat.DataPath, a.Metricbeat.LogPath))
workflow.AddAction(zitilib_actions.StartConsul("*", a.Consul.ServerAddr, a.Consul.ConfigDir, a.Consul.DataPath, a.Consul.LogPath))
workflow.AddAction(semaphore.Sleep(2 * time.Second))
workflow.AddAction(component.StartInParallel(".sdk-app", 5))

workflow.AddAction(semaphore.Sleep(5 * time.Second))
workflow.AddAction(zitilib_actions.Edge("list", "edge-routers", "limit none"))
workflow.AddAction(zitilib_actions.Edge("list", "terminators", "limit none"))

return workflow
}

Expand Down
20 changes: 18 additions & 2 deletions zititest/models/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ var Model = &model.Model{
Scope: model.Scope{Tags: model.Tags{"sdk-app", "service"}},
Type: &zitilab.EchoServerType{},
},
"iperf-server-ert": {
Scope: model.Scope{Tags: model.Tags{"iperf", "service"}},
Type: &zitilab.IPerfServerType{},
},
},
},
"ziti-edge-tunnel-host": {
Expand All @@ -174,6 +178,10 @@ var Model = &model.Model{
Version: "v0.21.4",
},
},
"iperf-server-zet": {
Scope: model.Scope{Tags: model.Tags{"iperf", "service"}},
Type: &zitilab.IPerfServerType{},
},
},
},
"ziti-tunnel-host": {
Expand All @@ -184,6 +192,10 @@ var Model = &model.Model{
Mode: zitilab.ZitiTunnelModeHost,
},
},
"iperf-server-zt": {
Scope: model.Scope{Tags: model.Tags{"iperf", "service"}},
Type: &zitilab.IPerfServerType{},
},
},
},
},
Expand All @@ -209,8 +221,12 @@ var Model = &model.Model{

Infrastructure: model.Stages{
aws_ssh_key.Express(),
terraform_0.Express(),
semaphore0.Ready(time.Minute),
&terraform_0.Terraform{
Retries: 3,
ReadyCheck: &semaphore0.ReadyStage{
MaxWait: 90 * time.Second,
},
},
},

Distribution: model.Stages{
Expand Down
88 changes: 63 additions & 25 deletions zititest/tests/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ var hashes = map[string]string{
}

var timeouts = map[string]time.Duration{
"1KB": 5 * time.Second,
"100KB": 5 * time.Second,
"1KB": 10 * time.Second,
"100KB": 10 * time.Second,
"20MB": 40 * time.Second,
}

Expand All @@ -44,38 +44,69 @@ const (
ClientWget httpClient = "wget"
)

func TestCurlFiles(t *testing.T) {
func TestDownloadFiles(t *testing.T) {
allZetHostedFailed := true
for _, hostType := range []string{"ert", "zet", "ziti-tunnel"} {
for _, clientType := range []string{"ert", "zet", "ziti-tunnel"} {
for _, encrypted := range []bool{true, false} {
success := testFileDownload(t, clientType, ClientCurl, hostType, encrypted, "1KB")
if hostType == "zet" && success {
allZetHostedFailed = false
allZetClientsFailed := true

t.Run("download-tests", func(t *testing.T) {
t.Run("test-ert-downloads", func(t *testing.T) {
t.Parallel()

for _, size := range []string{"1KB", "100KB", "20MB"} {
for _, hostType := range []string{"ert", "zet", "ziti-tunnel"} {
for _, client := range []httpClient{ClientCurl, ClientWget} {
for _, encrypted := range []bool{true, false} {
success := testFileDownload(t, "ert", client, hostType, encrypted, size)
if hostType == "zet" && success {
allZetHostedFailed = false
}
}
}
}
}
}
}

for _, size := range []string{"100KB", "20MB"} {
for _, clientType := range []string{"ert", "zet"} {
for _, hostType := range []string{"ert", "zet"} {
for _, client := range []httpClient{ClientCurl, ClientWget} {
for _, encrypted := range []bool{true, false} {
success := testFileDownload(t, clientType, client, hostType, encrypted, size)
if hostType == "zet" && success {
allZetHostedFailed = false
})

t.Run("test-zet-downloads", func(t *testing.T) {
t.Parallel()

for _, size := range []string{"1KB", "100KB", "20MB"} {
for _, hostType := range []string{"zet", "ziti-tunnel", "ert"} {
for _, client := range []httpClient{ClientCurl, ClientWget} {
for _, encrypted := range []bool{true, false} {
success := testFileDownload(t, "zet", client, hostType, encrypted, size)
if hostType == "zet" && success {
allZetHostedFailed = false
}
if success {
allZetClientsFailed = false
}
}
}
}
}
}
}

testFileDownload(t, "ziti-tunnel", ClientCurl, "ziti-tunnel", true, "20MB")
})

t.Run("test-ziti-tunnel-downloads", func(t *testing.T) {
t.Parallel()

for _, size := range []string{"1KB", "100KB", "20MB"} {
for _, hostType := range []string{"ziti-tunnel", "ert", "zet"} {
for _, client := range []httpClient{ClientCurl, ClientWget} {
for _, encrypted := range []bool{true, false} {
success := testFileDownload(t, "ziti-tunnel", client, hostType, encrypted, size)
if hostType == "zet" && success {
allZetHostedFailed = false
}
}
}
}
}
})
})

req := require.New(t)
req.False(allZetHostedFailed, "all zet hosted file transfer should not failed, indicates bigger issue")
req.False(allZetClientsFailed, "all zet client file transfers should not failed, indicates bigger issue")
}

func testFileDownload(t *testing.T, hostSelector string, client httpClient, hostType string, encrypted bool, fileSize string) bool {
Expand All @@ -96,7 +127,7 @@ func testFileDownload(t *testing.T, hostSelector string, client httpClient, host
urlExtra = "-unencrypted"
}

url := fmt.Sprintf("https://ziti-files-%s%s.s3-us-west-1.amazonaws.ziti/%s.zip", hostType, urlExtra, fileSize)
url := fmt.Sprintf("https://files-%s%s.s3-us-west-1.amazonaws.ziti/%s.zip", hostType, urlExtra, fileSize)
sshConfigFactory := lib.NewSshConfigFactory(host)

var cmd string
Expand All @@ -112,6 +143,13 @@ func testFileDownload(t *testing.T, hostSelector string, client httpClient, host
t.Skipf("zet hosted file transfer failed [%v]", err.Error())
return
}

if hostSelector == "zet" && err != nil {
t.Skipf("zet client file transfer failed [%v]", err.Error())
return
}

t.Log(o)
req.NoError(err)
req.Equal(hashes[fileSize], o[0:32])
success = true
Expand Down
Loading

0 comments on commit 02b979c

Please sign in to comment.