2021-06-09 15:37:03 +00:00
|
|
|
package control_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
control "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/ir"
|
2021-06-09 15:37:03 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
)
|
|
|
|
|
|
|
|
type protoMessage interface {
|
2022-05-31 17:00:41 +00:00
|
|
|
StableMarshal([]byte) []byte
|
2021-06-09 15:37:03 +00:00
|
|
|
proto.Message
|
|
|
|
}
|
|
|
|
|
|
|
|
func testStableMarshal(t *testing.T, m1, m2 protoMessage, cmp func(m1, m2 protoMessage) bool) {
|
2022-05-31 17:00:41 +00:00
|
|
|
require.NoError(t, proto.Unmarshal(m1.StableMarshal(nil), m2))
|
2021-06-09 15:37:03 +00:00
|
|
|
|
|
|
|
require.True(t, cmp(m1, m2))
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestHealthCheckResponse_Body_StableMarshal(t *testing.T) {
|
|
|
|
testStableMarshal(t,
|
|
|
|
generateHealthCheckResponseBody(),
|
|
|
|
new(control.HealthCheckResponse_Body),
|
|
|
|
func(m1, m2 protoMessage) bool {
|
|
|
|
return equalHealthCheckResponseBodies(
|
|
|
|
m1.(*control.HealthCheckResponse_Body),
|
|
|
|
m2.(*control.HealthCheckResponse_Body),
|
|
|
|
)
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body {
|
|
|
|
body := new(control.HealthCheckResponse_Body)
|
|
|
|
body.SetHealthStatus(control.HealthStatus_SHUTTING_DOWN)
|
|
|
|
|
|
|
|
return body
|
|
|
|
}
|
|
|
|
|
|
|
|
func equalHealthCheckResponseBodies(b1, b2 *control.HealthCheckResponse_Body) bool {
|
|
|
|
return b1.GetHealthStatus() == b2.GetHealthStatus()
|
|
|
|
}
|