[#1604] policer/test: Add test for MAINTENANCE runtime status

The node can have MAINTENANCE status in the network map, but can also be
ONLINE while responding with MAINTENANCE. These are 2 different code
paths, let's test them separately.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2025-01-16 16:22:37 +03:00
parent 4538ccb12a
commit 26e0c82fb8
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg

View file

@ -78,6 +78,7 @@ func TestProcessObject(t *testing.T) {
maintenanceNodes []int
wantRemoveRedundant bool
wantReplicateTo []int
headResult map[int]error
ecInfo *objectcore.ECInfo
}{
{
@ -145,6 +146,14 @@ func TestProcessObject(t *testing.T) {
objHolders: []int{1},
maintenanceNodes: []int{2},
},
{
desc: "preserve local copy when node response with MAINTENANCE",
nodeCount: 3,
policy: `REP 2`,
placement: [][]int{{1, 2}},
objHolders: []int{1},
headResult: map[int]error{2: new(apistatus.NodeUnderMaintenance)},
},
{
desc: "lock object must be replicated to all EC nodes",
objType: objectSDK.TypeLock,
@ -204,6 +213,11 @@ func TestProcessObject(t *testing.T) {
t.Errorf("unexpected remote object head: node=%+v addr=%v", ni, a)
return nil, errors.New("unexpected object head")
}
if ti.headResult != nil {
if err, ok := ti.headResult[index]; ok {
return nil, err
}
}
for _, i := range ti.objHolders {
if index == i {
return nil, nil