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 22, 2023
1 parent 3cd0313 commit abd05ab
Show file tree
Hide file tree
Showing 8 changed files with 340 additions and 73 deletions.
91 changes: 44 additions & 47 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 Down Expand Up @@ -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
1 change: 1 addition & 0 deletions zititest/models/simple/actions/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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))
Expand Down
12 changes: 12 additions & 0 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 Down
Empty file added zititest/report.xml
Empty file.
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 abd05ab

Please sign in to comment.