2019-12-23 20:48:20 +00:00
|
|
|
package super_block
|
2014-09-01 06:25:54 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-04-19 04:43:36 +00:00
|
|
|
|
2022-07-29 07:17:28 +00:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle"
|
2014-09-01 06:25:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSuperBlockReadWrite(t *testing.T) {
|
|
|
|
rp, _ := NewReplicaPlacementFromByte(byte(001))
|
2019-04-19 04:43:36 +00:00
|
|
|
ttl, _ := needle.ReadTTL("15d")
|
2014-09-01 06:25:54 +00:00
|
|
|
s := &SuperBlock{
|
2019-12-23 20:48:20 +00:00
|
|
|
Version: needle.CurrentVersion,
|
2014-09-01 06:25:54 +00:00
|
|
|
ReplicaPlacement: rp,
|
2014-09-20 19:38:59 +00:00
|
|
|
Ttl: ttl,
|
2014-09-01 06:25:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bytes := s.Bytes()
|
|
|
|
|
2019-04-19 04:43:36 +00:00
|
|
|
if !(bytes[2] == 15 && bytes[3] == needle.Day) {
|
2014-09-20 19:38:59 +00:00
|
|
|
println("byte[2]:", bytes[2], "byte[3]:", bytes[3])
|
2014-09-01 06:25:54 +00:00
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|