Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelkrolevets committed Oct 4, 2024
1 parent f3ff2f5 commit fe7e089
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 29 additions & 2 deletions integration_test/health_check_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package integration_test

import (
"io"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -38,11 +40,36 @@ func TestHealthCheck(t *testing.T) {
RootCmd.Short = "ssv-dkg-test"
RootCmd.Version = version
cli_initiator.HealthCheck.Version = version
t.Run("test 4 operators health check", func(t *testing.T) {
args := []string{"ping", "--ip", strings.Join(ips, ",")}
t.Run("test 1 operator health check: positive", func(t *testing.T) {
rescueStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
args := []string{"ping", "--ip", ips[0]}
RootCmd.SetArgs(args)
err := RootCmd.Execute()
require.NoError(t, err)
w.Close()
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout
t.Log(string(out))
require.True(t, strings.Contains(string(out), "operator online and healthy: multisig ready πŸ‘Œ and connected to ethereum network"))
resetFlags(RootCmd)
})
t.Run("test 1 operator health check: negative", func(t *testing.T) {
servers[0].HttpSrv.Close()
rescueStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
args := []string{"ping", "--ip", ips[0]}
RootCmd.SetArgs(args)
err := RootCmd.Execute()
require.NoError(t, err)
w.Close()
out, _ := io.ReadAll(r)
os.Stdout = rescueStdout
t.Log(string(out))
require.True(t, strings.Contains(string(out), "operator not healthy"))
require.True(t, strings.Contains(string(out), "connection refused"))
resetFlags(RootCmd)
})
for _, srv := range servers {
Expand Down
2 changes: 1 addition & 1 deletion pkgs/initiator/initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ func (c *Initiator) processPongMessage(res wire.PongResult) error {
c.Logger.Info("🟒 operator online and healthy: multisig ready πŸ‘Œ but NOT connected to ethereum network 🚫", zap.Uint64("ID", pong.ID), zap.String("IP", res.IP), zap.String("Version", string(signedPongMsg.Message.Version)), zap.String("Public key", string(pong.PubKey)))
}
} else {
c.Logger.Info("🟒 operator online: but NOT multisig ready 🚫", zap.Uint64("ID", pong.ID), zap.String("IP", res.IP), zap.String("Version", string(signedPongMsg.Message.Version)), zap.String("Public key", string(pong.PubKey)))
c.Logger.Error("πŸ”΄ operator online: but NOT multisig ready", zap.Uint64("ID", pong.ID), zap.String("IP", res.IP), zap.String("Version", string(signedPongMsg.Message.Version)), zap.String("Public key", string(pong.PubKey)))
}
return nil
}
Expand Down

0 comments on commit fe7e089

Please sign in to comment.