mirror of
https://github.com/openziti/ziti.git
synced 2026-10-11 15:10:59 +00:00
Make test labels better. Fix ZET scp tests
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
datacenter = "ziti-build-metrics"
|
||||
data_dir = "/opt/consul"
|
||||
encrypt = "${encryption_key}"
|
||||
advertise_addr="${public_ip}"
|
||||
|
||||
|
||||
tls {
|
||||
defaults {
|
||||
verify_incoming = false
|
||||
verify_outgoing = true
|
||||
|
||||
ca_file="consul/consul-agent-ca.pem"
|
||||
}
|
||||
}
|
||||
|
||||
auto_encrypt {
|
||||
tls = true
|
||||
}
|
||||
|
||||
acl {
|
||||
enabled = true
|
||||
default_policy = "allow"
|
||||
enable_token_persistence = true
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
[logstash-6.x]
|
||||
name=Elastic repository for 6.x packages
|
||||
baseurl=https://artifacts.elastic.co/packages/6.x/yum
|
||||
gpgcheck=1
|
||||
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
|
||||
enabled=1
|
||||
autorefresh=1
|
||||
type=rpm-md
|
||||
@@ -1,53 +0,0 @@
|
||||
fields_under_root: true
|
||||
fields:
|
||||
build_number: ${build_number}
|
||||
ziti_version: ${ziti_version}
|
||||
|
||||
processors:
|
||||
- add_cloud_metadata: ~
|
||||
|
||||
metricbeat.modules:
|
||||
- module: system
|
||||
metricsets:
|
||||
- cpu # CPU usage
|
||||
- load # CPU load averages
|
||||
- memory # Memory usage
|
||||
- network # Network IO
|
||||
enabled: true
|
||||
period: 30s
|
||||
cpu.metrics: ["percentages"] # The other available options are normalized_percentages and ticks.
|
||||
core.metrics: ["percentages"] # The other available option is ticks.
|
||||
#- module: docker
|
||||
# metricsets:
|
||||
# - "container"
|
||||
# - "cpu"
|
||||
# - "diskio"
|
||||
# - "healthcheck"
|
||||
# - "info"
|
||||
# - "image"
|
||||
# - "memory"
|
||||
# - "network"
|
||||
# hosts: ["unix:///var/run/docker.sock"]
|
||||
# period: 30s
|
||||
# enabled: true
|
||||
# # If set to true, replace dots in labels with `_`.
|
||||
# labels.dedot: true
|
||||
|
||||
|
||||
output.elasticsearch:
|
||||
# Array of hosts to connect to.
|
||||
hosts: ["${host}"]
|
||||
|
||||
# Optional protocol and basic auth credentials.
|
||||
protocol: "https"
|
||||
username: "${user}"
|
||||
password: "${password}"
|
||||
index: 'zt-%{[agent.version]}-%{+yyyy.MM.dd}'
|
||||
|
||||
setup.template.enabled: true
|
||||
setup.template.name: 'zt-%{[agent.version]}'
|
||||
setup.template.pattern: 'zt-%{[agent.version]}-*'
|
||||
setup.template.fields: "/etc/metricbeat/fields.yml"
|
||||
setup.template.settings:
|
||||
index.number_of_shards: 1
|
||||
index.codec: best_compression
|
||||
@@ -1,9 +0,0 @@
|
||||
service {
|
||||
name = "ziti"
|
||||
id = "ziti"
|
||||
port = 6262
|
||||
meta {
|
||||
build_number= "${build_number}"
|
||||
ziti_version= "${ziti_version}"
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,8 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const ZitiEdgeTunnelVersion = "v0.21.4"
|
||||
|
||||
//go:embed configs
|
||||
var configResource embed.FS
|
||||
|
||||
@@ -156,7 +158,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,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -206,7 +208,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": {
|
||||
@@ -235,19 +237,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{
|
||||
@@ -262,68 +254,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(),
|
||||
},
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
+35
-32
@@ -76,8 +76,7 @@ func TestScp(t *testing.T) {
|
||||
req := require.New(t)
|
||||
req.False(allZetHostedFailed, "all zet hosted file transfer should not failed, indicates bigger issue")
|
||||
|
||||
// TODO: fix once ZET client tests are working
|
||||
req.True(allZetClientsFailed, "all zet client file transfers should not failed, indicates bigger issue")
|
||||
req.False(allZetClientsFailed, "all zet client file transfers should not failed, indicates bigger issue")
|
||||
}
|
||||
|
||||
func testScp(t *testing.T, hostSelector string, hostType string, encrypted bool) bool {
|
||||
@@ -88,40 +87,44 @@ func testScp(t *testing.T, hostSelector string, hostType string, encrypted bool)
|
||||
|
||||
success := false
|
||||
|
||||
t.Run(fmt.Sprintf("(%s->%s)-%v", hostSelector, hostType, encDesk), func(t *testing.T) {
|
||||
if hostSelector == "zet" {
|
||||
t.Skipf("zet is currently failing as client")
|
||||
}
|
||||
host, err := model.GetModel().SelectHost("." + hostSelector + "-client")
|
||||
req := require.New(t)
|
||||
req.NoError(err)
|
||||
nameExtra := ""
|
||||
if !encrypted {
|
||||
nameExtra = "-unencrypted"
|
||||
}
|
||||
|
||||
nameExtra := ""
|
||||
if !encrypted {
|
||||
nameExtra = "-unencrypted"
|
||||
}
|
||||
tests := []struct {
|
||||
direction string
|
||||
cmd string
|
||||
}{
|
||||
{
|
||||
direction: "<-",
|
||||
cmd: fmt.Sprintf("scp -o StrictHostKeyChecking=no scp://ssh-%s%s.ziti:2022/fablab/bin/ziti /tmp/ziti-%s", hostType, nameExtra, uuid.NewString()),
|
||||
}, {
|
||||
direction: "->",
|
||||
cmd: fmt.Sprintf("scp -o StrictHostKeyChecking=no ./fablab/bin/ziti scp://ssh-%s%s.ziti:2022//tmp/ziti-%s", hostType, nameExtra, uuid.NewString()),
|
||||
},
|
||||
}
|
||||
|
||||
sshConfigFactory := lib.NewSshConfigFactory(host)
|
||||
for _, test := range tests {
|
||||
t.Run(fmt.Sprintf("(%s%s%s)-%v", hostSelector, test.direction, hostType, encDesk), func(t *testing.T) {
|
||||
host, err := model.GetModel().SelectHost("." + hostSelector + "-client")
|
||||
req := require.New(t)
|
||||
req.NoError(err)
|
||||
|
||||
cmds := []string{
|
||||
fmt.Sprintf("scp -o StrictHostKeyChecking=no ssh-%s%s.ziti:./fablab/bin/ziti /tmp/ziti-%s", hostType, nameExtra, uuid.NewString()),
|
||||
fmt.Sprintf("scp -o StrictHostKeyChecking=no ./fablab/bin/ziti ssh-%s%s.ziti:/tmp/ziti-%s", hostType, nameExtra, uuid.NewString()),
|
||||
}
|
||||
sshConfigFactory := lib.NewSshConfigFactory(host)
|
||||
|
||||
o, err := lib.RemoteExecAllWithTimeout(sshConfigFactory, 30*time.Second, cmds...)
|
||||
if hostType == "zet" && err != nil {
|
||||
t.Skipf("zet hosted ssh failed [%v]", err.Error())
|
||||
return
|
||||
}
|
||||
o, err := lib.RemoteExecAllWithTimeout(sshConfigFactory, 50*time.Second, test.cmd)
|
||||
if hostType == "zet" && err != nil {
|
||||
t.Skipf("zet hosted ssh failed [%v]", err.Error())
|
||||
} else if hostSelector == "zet" && err != nil {
|
||||
t.Skipf("zet client ssh failed [%v]", err.Error())
|
||||
} else {
|
||||
t.Log(o)
|
||||
req.NoError(err)
|
||||
success = true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if hostSelector == "zet" && err != nil {
|
||||
t.Skipf("zet client ssh failed [%v]", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
t.Log(o)
|
||||
req.NoError(err)
|
||||
success = true
|
||||
})
|
||||
return success
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user