Skip to content

Commit

Permalink
Merge pull request #1447 from openziti/tidy-test-names
Browse files Browse the repository at this point in the history
Make test labels better. Fix ZET scp tests
  • Loading branch information
plorenz authored Oct 18, 2023
2 parents ba09965 + e044394 commit 6c035be
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 244 deletions.
24 changes: 2 additions & 22 deletions zititest/models/simple/actions/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ import (
"github.com/openziti/ziti/zititest/zitilab/models"
)

func NewStartAction(metricbeat MetricbeatConfig, consul ConsulConfig) model.ActionBinder {
action := &startAction{
Metricbeat: metricbeat,
Consul: consul,
}
func NewStartAction() model.ActionBinder {
action := &startAction{}
return action.bind
}

Expand All @@ -44,8 +41,6 @@ func (a *startAction) bind(m *model.Model) model.Action {
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))

Expand All @@ -57,19 +52,4 @@ func (a *startAction) bind(m *model.Model) model.Action {
}

type startAction struct {
Metricbeat MetricbeatConfig
Consul ConsulConfig
}

type MetricbeatConfig struct {
ConfigPath string
DataPath string
LogPath string
}

type ConsulConfig struct {
ConfigDir string
ServerAddr string
DataPath string
LogPath string
}
24 changes: 0 additions & 24 deletions zititest/models/simple/configs/consul.hcl

This file was deleted.

8 changes: 0 additions & 8 deletions zititest/models/simple/configs/elasticsearch.repo

This file was deleted.

53 changes: 0 additions & 53 deletions zititest/models/simple/configs/metricbeat.yml

This file was deleted.

9 changes: 0 additions & 9 deletions zititest/models/simple/configs/ziti.hcl

This file was deleted.

117 changes: 30 additions & 87 deletions zititest/models/simple/simple.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package simple

import (
"embed"
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/fablab/kernel/lib/actions/component"
"github.com/openziti/fablab/kernel/lib/binding"
Expand All @@ -35,22 +34,15 @@ import (
"github.com/openziti/ziti/zititest/models/test_resources"
"github.com/openziti/ziti/zititest/zitilab"
"github.com/openziti/ziti/zititest/zitilab/actions/edge"
"github.com/sirupsen/logrus"
"os"
"time"
)

const ZitiEdgeTunnelVersion = "v0.22.11"

//go:embed configs
var configResource embed.FS

func getConfigData(filePath string) []byte {
data, err := configResource.ReadFile(fmt.Sprintf("configs/%s", filePath))
if err != nil {
logrus.Errorf("Unable to read config data from %s: [%s]", filePath, err)
}
return data
}

func getUniqueId() string {
if runId := os.Getenv("GITHUB_RUN_ID"); runId != "" {
return "-" + runId + "." + os.Getenv("GITHUB_RUN_ATTEMPT")
Expand Down Expand Up @@ -101,6 +93,29 @@ var Model = &model.Model{
return nil
})
}),

model.FactoryFunc(func(m *model.Model) error {
zetPath, useLocalPath := m.GetStringVariable("local_zet_path")
return m.ForEachComponent("*", 1, func(c *model.Component) error {
if c.Type == nil {
return nil
}

if zet, ok := c.Type.(*zitilab.ZitiEdgeTunnelType); ok {
if useLocalPath {
zet.Version = ""
zet.LocalPath = zetPath
} else {
zet.Version = ZitiEdgeTunnelVersion
zet.LocalPath = ""
}
zet.InitType(c)
return nil
}

return nil
})
}),
},

Resources: model.Resources{
Expand Down Expand Up @@ -156,7 +171,7 @@ var Model = &model.Model{
"ziti-edge-tunnel-client": {
Scope: model.Scope{Tags: model.Tags{"sdk-app", "client"}},
Type: &zitilab.ZitiEdgeTunnelType{
Version: "v0.21.4",
Version: ZitiEdgeTunnelVersion,
},
},
},
Expand Down Expand Up @@ -206,7 +221,7 @@ var Model = &model.Model{
"ziti-edge-tunnel-host": {
Scope: model.Scope{Tags: model.Tags{"sdk-app", "host", "zet-host"}},
Type: &zitilab.ZitiEdgeTunnelType{
Version: "v0.21.4",
Version: ZitiEdgeTunnelVersion,
},
},
"iperf-server-zet": {
Expand Down Expand Up @@ -235,19 +250,9 @@ var Model = &model.Model{

Actions: model.ActionBinders{
"bootstrap": actions.NewBootstrapAction(),
"start": actions.NewStartAction(actions.MetricbeatConfig{
ConfigPath: "metricbeat",
DataPath: "metricbeat/data",
LogPath: "metricbeat/logs",
},
actions.ConsulConfig{
ServerAddr: os.Getenv("CONSUL_ENDPOINT"),
ConfigDir: "consul",
DataPath: "consul/data",
LogPath: "consul/log.out",
}),
"stop": model.Bind(component.StopInParallel("*", 15)),
"login": model.Bind(edge.Login("#ctrl1")),
"start": actions.NewStartAction(),
"stop": model.Bind(component.StopInParallel("*", 15)),
"login": model.Bind(edge.Login("#ctrl1")),
},

Infrastructure: model.Stages{
Expand All @@ -262,68 +267,6 @@ var Model = &model.Model{

Distribution: model.Stages{
distribution.DistributeSshKey("*"),
distribution.Locations("*", "logs"),
distribution.DistributeDataWithReplaceCallbacks(
"*",
string(getConfigData("metricbeat.yml")),
"metricbeat/metricbeat.yml",
os.FileMode(0644),
map[string]func(*model.Host) string{
"${host}": func(h *model.Host) string {
return os.Getenv("ELASTIC_ENDPOINT")
},
"${user}": func(h *model.Host) string {
return os.Getenv("ELASTIC_USERNAME")
},
"${password}": func(h *model.Host) string {
return os.Getenv("ELASTIC_PASSWORD")
},
"${build_number}": func(h *model.Host) string {
return os.Getenv("BUILD_NUMBER")
},
"${ziti_version}": func(h *model.Host) string {
return h.MustStringVariable("ziti_version")
},
},
),

distribution.DistributeDataWithReplaceCallbacks(
"*",
string(getConfigData("consul.hcl")),
"consul/consul.hcl",
os.FileMode(0644),
map[string]func(*model.Host) string{
"${public_ip}": func(h *model.Host) string {
return h.PublicIp
},
"${encryption_key}": func(h *model.Host) string {
return os.Getenv("CONSUL_ENCRYPTION_KEY")
},
"${build_number}": func(h *model.Host) string {
return os.Getenv("BUILD_NUMBER")
},
"${ziti_version}": func(h *model.Host) string {
return h.MustStringVariable("ziti_version")
},
},
),
distribution.DistributeDataWithReplaceCallbacks(
"#ctrl",
string(getConfigData("ziti.hcl")),
"consul/ziti.hcl",
os.FileMode(0644),
map[string]func(*model.Host) string{
"${build_number}": func(h *model.Host) string {
return os.Getenv("BUILD_NUMBER")
},
"${ziti_version}": func(h *model.Host) string {
return h.MustStringVariable("ziti_version")
},
}),
distribution.DistributeData(
"*",
[]byte(os.Getenv("CONSUL_AGENT_CERT")),
"consul/consul-agent-ca.pem"),
rsync.RsyncStaged(),
},

Expand Down
2 changes: 1 addition & 1 deletion zititest/tests/files_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func testFileDownload(t *testing.T, hostSelector string, client httpClient, host

success := false

t.Run(fmt.Sprintf("%v-(%s->%s)-%s-%v", client, hostSelector, hostType, fileSize, encDesk), func(t *testing.T) {
t.Run(fmt.Sprintf("%v-(%s<-%s)-%s-%v", client, hostSelector, hostType, fileSize, encDesk), func(t *testing.T) {
host, err := model.GetModel().SelectHost("." + hostSelector + "-client")
req := require.New(t)
req.NoError(err)
Expand Down
Loading

0 comments on commit 6c035be

Please sign in to comment.