-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The ad-hoc parser for the output of drbdsetup status would sometimes fail. This was caused by large values in fields that only expected "int". Instead of manually checking the possible range, we can just remove those fields, as they do not hold any relevant information for the inner workings of the HA Controller. Signed-off-by: Moritz "WanzenBug" Wanzenböck <[email protected]>
- Loading branch information
Showing
3 changed files
with
42 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package agent_test | ||
|
||
import ( | ||
"encoding/json" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/piraeusdatastore/piraeus-ha-controller/pkg/agent" | ||
) | ||
|
||
func TestUnmarshalDrbdResourceState(t *testing.T) { | ||
source := `[{"peer-node-id":0,"name":"4b","connection-state":"Connecting","congested":false,"peer-role":"Unknown","ap-in-flight":18446744073709551608,"rs-in-flight":0,"peer_devices":[{"volume":0,"replication-state":"Off","peer-disk-state":"DUnknown","peer-client":false,"resync-suspended":"no","received":0,"sent":0,"out-of-sync":0,"pending":0,"unacked":0,"has-sync-details":false,"has-online-verify-details":false,"percent-in-sync":100.00}]}]` | ||
|
||
var result []agent.DrbdResourceState | ||
err := json.Unmarshal([]byte(source), &result) | ||
assert.NoError(t, err) | ||
assert.Equal(t, []agent.DrbdResourceState{ | ||
{ | ||
Name: "4b", | ||
Role: "", | ||
ForceIoFailures: false, | ||
Suspended: false, | ||
}, | ||
}, result) | ||
} |