Skip to content

Commit

Permalink
FMWK-586-fix-todos
Browse files Browse the repository at this point in the history
- fix todos
  • Loading branch information
filkeith committed Oct 29, 2024
1 parent 3116628 commit 4b806dc
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion internal/asinfo/info_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ func parseInfoKVPair(pair, kvSep string) (key, val string, err error) {
}

// parseSindexListResponse parses a sindex-list info response
// TODO example response
// example resp: ns=source-ns1:indexname=idx_timestamp:set=metrics:bin=timestamp:type=numeric:indextype=default
func parseSindexListResponse(resp string) ([]infoMap, error) {
return parseInfoResponse(resp, ";", ":", "=")
}
Expand Down
2 changes: 0 additions & 2 deletions io/aerospike/sindex_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ type sindexWriter struct {
}

// writeSecondaryIndex writes a secondary index to Aerospike.
// TODO check that this does not overwrite existing sindexes
// TODO support write policy
func (rw sindexWriter) writeSecondaryIndex(si *models.SIndex) error {
var sindexType a.IndexType

Expand Down
2 changes: 0 additions & 2 deletions io/aerospike/udf_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ type udfWriter struct {
}

// writeUDF writes a UDF to Aerospike.
// TODO check that this does not overwrite existing UDFs
// TODO support write policy
func (rw udfWriter) writeUDF(udf *models.UDF) error {
var UDFLang a.Language

Expand Down
9 changes: 6 additions & 3 deletions io/encoding/asb/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"github.com/aerospike/backup-go/models"
)

const supportedVersion = "3.1"

func newDecoderError(offset uint64, err error) error {
if errors.Is(err, io.EOF) {
return err
Expand Down Expand Up @@ -112,8 +114,11 @@ func NewDecoder(src io.Reader) (*Decoder, error) {
return nil, fmt.Errorf("error while reading header: %w", err)
}

if header.Version != supportedVersion {
return nil, fmt.Errorf("unsupported backup file version: %s", header.Version)
}

asb.header = header
// TODO make sure file version is 3.1

meta, err := asb.readMetadata()
if err != nil {
Expand Down Expand Up @@ -966,8 +971,6 @@ func (r *Decoder) readBinCount() (uint16, error) {
// readExpiration reads an expiration line from the asb file
// it expects that r has been advanced past the expiration line marker '+ t '
// NOTE: we don't check the expiration against any bounds because negative (large) expirations are valid
// TODO expiration needs to be updated based on how much time has passed since the backup.
// I think that should be done in a processor though, not here
func (r *Decoder) readExpiration() (int64, error) {
exp, err := _readInteger(r, '\n')
if err != nil {
Expand Down
18 changes: 2 additions & 16 deletions io/encoding/asb/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
a "github.com/aerospike/aerospike-client-go/v7"
particleType "github.com/aerospike/aerospike-client-go/v7/types/particle_type"
"github.com/aerospike/backup-go/models"
"github.com/google/go-cmp/cmp"
"github.com/stretchr/testify/assert"
)

func TestASBReader_readHeader(t *testing.T) {
Expand Down Expand Up @@ -1949,17 +1949,6 @@ func TestASBReader_readRecord(t *testing.T) {
},
}

// allow comp.Diff to compare aerospike keys
keyCmp := cmp.Comparer(func(x, y *a.Key) bool {
if x == nil || y == nil {
return x == y
}
if !x.Equals(y) {
return false
}
return x.String() == y.String()
})

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := &Decoder{
Expand All @@ -1972,10 +1961,7 @@ func TestASBReader_readRecord(t *testing.T) {
t.Errorf("ASBReader.readRecord() error = %v, wantErr %v", err, tt.wantErr)
return
}
// TODO don't use cmp.Diff here, use testify instead
if diff := cmp.Diff(got, tt.want, keyCmp); diff != "" {
t.Errorf("ASBReader.readRecord() mismatch:\n%s", diff)
}
assert.EqualValues(t, got, tt.want)
})
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/test_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ func (tc *TestClient) ReadAllRecords(namespace, set string) (RecordMap, error) {
// It does this by reading all records in the database namespace and set, then comparing
// their digests and bins to the expected records' digests and bins.
// Currently, it does not compare the records' metadata, only their digests and bins.
// TODO compare metadata and user keys, maybe in another method
func (tc *TestClient) ValidateRecords(
t assert.TestingT, expectedRecs []*a.Record, namespace, set string) {
actualRecs, err := tc.ReadAllRecords(namespace, set)
Expand Down

0 comments on commit 4b806dc

Please sign in to comment.