diff --git a/internal/asinfo/info_client.go b/internal/asinfo/info_client.go index 5867f405..7af5df33 100644 --- a/internal/asinfo/info_client.go +++ b/internal/asinfo/info_client.go @@ -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, ";", ":", "=") } diff --git a/io/aerospike/sindex_writer.go b/io/aerospike/sindex_writer.go index 73609c76..f380bf4e 100644 --- a/io/aerospike/sindex_writer.go +++ b/io/aerospike/sindex_writer.go @@ -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 diff --git a/io/aerospike/udf_writer.go b/io/aerospike/udf_writer.go index 0356a885..03213fb2 100644 --- a/io/aerospike/udf_writer.go +++ b/io/aerospike/udf_writer.go @@ -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 diff --git a/io/encoding/asb/decode.go b/io/encoding/asb/decode.go index af8a2c5e..ef76db6d 100644 --- a/io/encoding/asb/decode.go +++ b/io/encoding/asb/decode.go @@ -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 @@ -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 { @@ -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 { diff --git a/io/encoding/asb/decode_test.go b/io/encoding/asb/decode_test.go index 3f07da67..994da609 100644 --- a/io/encoding/asb/decode_test.go +++ b/io/encoding/asb/decode_test.go @@ -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) { @@ -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{ @@ -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) }) } } diff --git a/tests/test_client.go b/tests/test_client.go index 54473b1c..13e97876 100644 --- a/tests/test_client.go +++ b/tests/test_client.go @@ -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)