Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit b79ce9b

Browse files
authored
test: fix print without linebreak results in unknown (#868)
- fix print without linebreak results in unknown, see issue gotestyourself/gotestsum#205 --------- Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
1 parent d0db4d6 commit b79ce9b

File tree

12 files changed

+37
-36
lines changed

12 files changed

+37
-36
lines changed

.github/workflows/test-ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
8888
- name: Archive logs
8989
if: ${{ !success() }}
90-
uses: actions/upload-artifact@v3
90+
uses: actions/upload-artifact@v4
9191
with:
9292
name: milvus-logs-${{ matrix.mode }}
9393
path: |

test/common/response_check.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func CheckInsertResult(t *testing.T, actualIds entity.Column, expIds entity.Colu
114114
case entity.FieldTypeVarChar:
115115
require.ElementsMatch(t, actualIds.(*entity.ColumnVarChar).Data(), expIds.(*entity.ColumnVarChar).Data())
116116
default:
117-
log.Printf("The primary field only support type: [%v, %v]", entity.FieldTypeInt64, entity.FieldTypeVarChar)
117+
log.Printf("The primary field only support type: [%v, %v] \n", entity.FieldTypeInt64, entity.FieldTypeVarChar)
118118
}
119119
}
120120

@@ -156,8 +156,8 @@ func EqualColumn(t *testing.T, columnA entity.Column, columnB entity.Column) {
156156
case entity.FieldTypeVarChar:
157157
require.ElementsMatch(t, columnA.(*entity.ColumnVarChar).Data(), columnB.(*entity.ColumnVarChar).Data())
158158
case entity.FieldTypeJSON:
159-
log.Printf("columnA: %s", columnA.FieldData())
160-
log.Printf("columnB: %s", columnB.FieldData())
159+
log.Printf("columnA: %s \n", columnA.FieldData())
160+
log.Printf("columnB: %s \n", columnB.FieldData())
161161
require.Equal(t, reflect.TypeOf(columnA), reflect.TypeOf(columnB))
162162
switch columnA.(type) {
163163
case *entity.ColumnDynamic:
@@ -178,7 +178,7 @@ func EqualColumn(t *testing.T, columnA entity.Column, columnB entity.Column) {
178178
case entity.FieldTypeArray:
179179
EqualArrayColumn(t, columnA, columnB)
180180
default:
181-
log.Printf("The column type not in: [%v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v]",
181+
log.Printf("The column type not in: [%v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v, %v] \n",
182182
entity.FieldTypeBool, entity.FieldTypeInt8, entity.FieldTypeInt16, entity.FieldTypeInt32,
183183
entity.FieldTypeInt64, entity.FieldTypeFloat, entity.FieldTypeDouble, entity.FieldTypeString,
184184
entity.FieldTypeVarChar, entity.FieldTypeArray, entity.FieldTypeFloatVector, entity.FieldTypeBinaryVector)
@@ -208,7 +208,7 @@ func EqualArrayColumn(t *testing.T, columnA entity.Column, columnB entity.Column
208208
case *entity.ColumnVarCharArray:
209209
require.ElementsMatch(t, columnA.(*entity.ColumnVarCharArray).Data(), columnB.(*entity.ColumnVarCharArray).Data())
210210
default:
211-
log.Printf("Now support array type: [%v, %v, %v, %v, %v, %v, %v, %v]",
211+
log.Printf("Now support array type: [%v, %v, %v, %v, %v, %v, %v, %v] \n",
212212
entity.FieldTypeBool, entity.FieldTypeInt8, entity.FieldTypeInt16, entity.FieldTypeInt32,
213213
entity.FieldTypeInt64, entity.FieldTypeFloat, entity.FieldTypeDouble, entity.FieldTypeVarChar)
214214
}
@@ -293,8 +293,8 @@ func CheckQueryIteratorResult(ctx context.Context, t *testing.T, itr *client.Que
293293
}
294294
log.Fatalf("QueryIterator next gets error: %v", err)
295295
}
296-
//log.Printf("QueryIterator result len: %d", rs.Len())
297-
//log.Printf("QueryIterator result data: %d", rs.GetColumn("int64"))
296+
//log.Printf("QueryIterator result len: %d \n", rs.Len())
297+
//log.Printf("QueryIterator result data: %d \n", rs.GetColumn("int64"))
298298

299299
if opt.expBatchSize != nil {
300300
actualBatchSize = append(actualBatchSize, rs.Len())
@@ -310,7 +310,7 @@ func CheckQueryIteratorResult(ctx context.Context, t *testing.T, itr *client.Que
310310
}
311311
require.Equal(t, expLimit, actualLimit)
312312
if opt.expBatchSize != nil {
313-
log.Printf("QueryIterator result len: %v", actualBatchSize)
313+
log.Printf("QueryIterator result len: %v \n", actualBatchSize)
314314
require.True(t, EqualIntSlice(opt.expBatchSize, actualBatchSize))
315315
}
316316
}

test/common/utils.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,11 +1398,8 @@ type InvalidExprStruct struct {
13981398
}
13991399

14001400
var InvalidExpressions = []InvalidExprStruct{
1401-
// https://github.com/milvus-io/milvus-sdk-go/issues/777
14021401
{Expr: "id in [0]", ErrNil: true, ErrMsg: "fieldName(id) not found"}, // not exist field but no error
14031402
{Expr: "int64 in not [0]", ErrNil: false, ErrMsg: "cannot parse expression"}, // wrong term expr keyword
1404-
{Expr: "int64 > 10 AND int64 < 100", ErrNil: false, ErrMsg: "cannot parse expression"}, // AND isn't supported
1405-
{Expr: "int64 < 10 OR int64 > 100", ErrNil: false, ErrMsg: "cannot parse expression"}, // OR isn't supported
14061403
{Expr: "int64 < floatVec", ErrNil: false, ErrMsg: "not supported"}, // unsupported compare field
14071404
{Expr: "floatVec in [0]", ErrNil: false, ErrMsg: "cannot be casted to FloatVector"}, // value and field type mismatch
14081405
{Expr: fmt.Sprintf("%s == 1", DefaultJSONFieldName), ErrNil: true, ErrMsg: ""}, // hist empty

test/testcases/collection_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func TestCreateAutoIdCollection(t *testing.T) {
7070

7171
// check describe collection
7272
collection, _ := mc.DescribeCollection(ctx, collName)
73-
log.Printf("collection schema autoid: %v", collection.Schema.AutoID)
74-
log.Printf("collection pk field autoid: %v", collection.Schema.Fields[0].AutoID)
73+
log.Printf("collection schema autoid: %v \n", collection.Schema.AutoID)
74+
log.Printf("collection pk field autoid: %v \n", collection.Schema.Fields[0].AutoID)
7575
common.CheckCollection(t, collection, collName, common.DefaultShards, schema, common.DefaultConsistencyLevel)
7676

7777
// check collName in ListCollections
@@ -345,8 +345,8 @@ func TestCreateCollectionInconsistentAutoId(t *testing.T) {
345345
errWithoutPk := mc.CreateCollection(ctx, schema, common.DefaultShards)
346346
common.CheckErr(t, errWithoutPk, true, "only one auto id is available")
347347
collection, _ := mc.DescribeCollection(ctx, collName)
348-
log.Printf("collection schema AutoID is %v)", collection.Schema.AutoID)
349-
log.Printf("collection pk field AutoID is %v)", collection.Schema.Fields[0].AutoID)
348+
log.Printf("collection schema AutoID is %v \n)", collection.Schema.AutoID)
349+
log.Printf("collection pk field AutoID is %v \n)", collection.Schema.Fields[0].AutoID)
350350
}
351351

352352
// test create collection with field description and schema description

test/testcases/configure_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestLoadCollectionReplicas(t *testing.T) {
3333
for _, replica := range replicas {
3434
require.Len(t, replica.ShardReplicas, int(common.DefaultShards))
3535
for _, shard := range replica.ShardReplicas {
36-
log.Printf("ReplicaID: %v, NodeIDs: %v, LeaderID: %v, NodesIDs: %v, DmChannelName: %v",
36+
log.Printf("ReplicaID: %v, NodeIDs: %v, LeaderID: %v, NodesIDs: %v, DmChannelName: %v \n",
3737
replica.ReplicaID, replica.NodeIDs, shard.LeaderID, shard.NodesIDs, shard.DmChannelName)
3838
}
3939
}
@@ -42,7 +42,7 @@ func TestLoadCollectionReplicas(t *testing.T) {
4242
segments, _ := mc.GetPersistentSegmentInfo(ctx, collName)
4343
common.CheckPersistentSegments(t, segments, int64(common.DefaultNb))
4444
for _, segment := range segments {
45-
log.Printf("segmentId: %d, NumRows: %d, CollectionID: %d, ParititionID %d, IndexId: %d, State %v",
45+
log.Printf("segmentId: %d, NumRows: %d, CollectionID: %d, ParititionID %d, IndexId: %d, State %v \n",
4646
segment.ID, segment.NumRows, segment.CollectionID, segment.ParititionID, segment.IndexID, segment.State)
4747
}
4848
}

test/testcases/groupby_search_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func TestSearchGroupByFloatDefault(t *testing.T) {
157157
groupByField,
158158
}, []entity.Vector{queryVec[i]}, common.DefaultFloatVecFieldName, metricType, 1, sp)
159159
filterTop1Pk, _ := resFilter[0].IDs.GetAsInt64(0)
160-
// log.Printf("Search top1 with %s: groupByValue: %v, pkValue: %d. The returned pk by filter search is: %d",
160+
//log.Printf("Search top1 with %s: groupByValue: %v, pkValue: %d. The returned pk by filter search is: %d \n",
161161
// groupByField, groupByValue, pkValue, filterTop1Pk)
162162
if filterTop1Pk == pkValue {
163163
hitsNum += 1
@@ -234,7 +234,7 @@ func TestGroupBySearchSparseVector(t *testing.T) {
234234
common.DefaultVarcharFieldName,
235235
}, []entity.Vector{queryVec[i]}, common.DefaultSparseVecFieldName, entity.IP, 1, sp)
236236
filterTop1Pk, _ := resFilter[0].IDs.GetAsInt64(0)
237-
log.Printf("Search top1 with %s: groupByValue: %v, pkValue: %d. The returned pk by filter search is: %d",
237+
log.Printf("Search top1 with %s: groupByValue: %v, pkValue: %d. The returned pk by filter search is: %d \n",
238238
common.DefaultVarcharFieldName, groupByValue, pkValue, filterTop1Pk)
239239
if filterTop1Pk == pkValue {
240240
hitsNum += 1
@@ -385,8 +385,8 @@ func TestSearchGroupByFloatGrowing(t *testing.T) {
385385

386386
// search filter with groupByValue is the top1
387387
filterTop1Pk, _ := resFilter[0].IDs.GetAsInt64(0)
388-
// log.Printf("Search top1 with %s: groupByValue: %v, pkValue: %d. The returned pk by filter search is: %d",
389-
// groupByField, groupByValue, pkValue, filterTop1Pk)
388+
log.Printf("Search top1 with %s: groupByValue: %v, pkValue: %d. The returned pk by filter search is: %d \n",
389+
groupByField, groupByValue, pkValue, filterTop1Pk)
390390
if filterTop1Pk == pkValue {
391391
hitsNum += 1
392392
}

test/testcases/index_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestCreateIndexMultiVectors(t *testing.T) {
8080
common.CheckErr(t, err, true)
8181
for _, idx := range common.GenAllFloatIndex() {
8282
for _, fieldName := range []string{common.DefaultFloat16VecFieldName, common.DefaultBFloat16VecFieldName} {
83-
log.Printf("index name=%s, index type=%v, index params=%v", idx.Name(), idx.IndexType(), idx.Params())
83+
log.Printf("index name=%s, index type=%v, index params=%v \n", idx.Name(), idx.IndexType(), idx.Params())
8484
err := mc.CreateIndex(ctx, collName, fieldName, idx, false, client.WithIndexName(fieldName))
8585
common.CheckErr(t, err, true)
8686

@@ -1529,7 +1529,7 @@ func TestDropIndexCreateIndex(t *testing.T) {
15291529
// describe collection
15301530
collection, _ := mc.DescribeCollection(ctx, collName)
15311531
for _, field := range collection.Schema.Fields {
1532-
log.Printf("field name: %v, field TypeParams: %v, field IndexParams: %v)", field.Name, field.TypeParams, field.IndexParams)
1532+
log.Printf("field name: %v, field TypeParams: %v, field IndexParams: %v \n)", field.Name, field.TypeParams, field.IndexParams)
15331533
}
15341534

15351535
// drop index
@@ -1552,6 +1552,6 @@ func TestDropIndexCreateIndex(t *testing.T) {
15521552
t.Log("Issue: https://github.com/milvus-io/milvus-sdk-go/issues/385")
15531553
collection2, _ := mc.DescribeCollection(ctx, collName)
15541554
for _, field := range collection2.Schema.Fields {
1555-
log.Printf("field name: %v, field TypeParams: %v, field IndexParams: %v)", field.Name, field.TypeParams, field.IndexParams)
1555+
log.Printf("field name: %v, field TypeParams: %v, field IndexParams: %v \n)", field.Name, field.TypeParams, field.IndexParams)
15561556
}
15571557
}

test/testcases/insert_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func TestInsertJsonCollection(t *testing.T) {
407407
rows := common.GenDefaultJSONRows(0, nb, common.DefaultDim, true)
408408
_, ok := rows[0].([]byte)
409409
if !ok {
410-
log.Printf("invalid type, expected []byte, got %T", rows)
410+
log.Printf("invalid type, expected []byte, got %T \n", rows)
411411
}
412412
_, errInsert := mc.InsertRows(ctx, collName, "", rows)
413413
common.CheckErr(t, errInsert, true)

test/testcases/load_release_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,12 @@ func TestLoadEmptyPartitionName(t *testing.T) {
142142
idx, _ := entity.NewIndexHNSW(entity.L2, 8, 96)
143143
mc.CreateIndex(ctx, collName, common.DefaultFloatVecFieldName, idx, false)
144144

145-
// load partition with empty partition names
145+
// load partition with empty partition names -> default
146146
errLoadEmpty := mc.LoadPartitions(ctx, collName, []string{""}, false)
147147
common.CheckErr(t, errLoadEmpty, true)
148+
149+
countQuery, _ := mc.Query(ctx, collName, []string{}, fmt.Sprintf("%s == 0", common.DefaultIntFieldName), []string{common.QueryCountFieldName})
150+
require.Equal(t, int64(1), countQuery.GetColumn(common.QueryCountFieldName).(*entity.ColumnInt64).Data()[0])
148151
}
149152

150153
// test load partitions with empty slice []string{}
@@ -221,7 +224,7 @@ func TestLoadPartitions(t *testing.T) {
221224
log.Println(p.Loaded)
222225
// require.True(t, p.Loaded)
223226
}
224-
log.Printf("id: %d, name: %s, loaded %t", p.ID, p.Name, p.Loaded)
227+
log.Printf("id: %d, name: %s, loaded %t \n", p.ID, p.Name, p.Loaded)
225228
}
226229

227230
// query from nb from partition
@@ -315,7 +318,7 @@ func TestLoadPartitionsAsync(t *testing.T) {
315318
partitions, errShow := mc.ShowPartitions(ctx, collName)
316319
if errShow == nil {
317320
for _, p := range partitions {
318-
log.Printf("id: %d, name: %s, loaded %t", p.ID, p.Name, p.Loaded)
321+
log.Printf("id: %d, name: %s, loaded %t \n", p.ID, p.Name, p.Loaded)
319322
if p.Name == partitionName && p.Loaded {
320323
break
321324
}

test/testcases/query_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ func TestQueryJsonDynamicFieldRows(t *testing.T) {
10431043
// gen dynamic json column
10441044

10451045
for _, column := range queryResult {
1046-
log.Printf("name: %s, type: %s, fieldData: %v", column.Name(), column.Type(), column.FieldData())
1046+
log.Printf("name: %s, type: %s, fieldData: %v \n", column.Name(), column.Type(), column.FieldData())
10471047
if column.Type() == entity.FieldTypeJSON {
10481048
var jsonData []string
10491049
for i := 0; i < column.Len(); i++ {
@@ -1644,7 +1644,7 @@ func TestQueryIteratorExpr(t *testing.T) {
16441644
batch := 500
16451645

16461646
for _, exprLimit := range exprLimits {
1647-
log.Printf("case expr is: %s, limit=%d", exprLimit.expr, exprLimit.count)
1647+
log.Printf("case expr is: %s, limit=%d \n", exprLimit.expr, exprLimit.count)
16481648
itr, err := mc.QueryIterator(ctx, client.NewQueryIteratorOption(collName).WithBatchSize(batch).WithExpr(exprLimit.expr))
16491649
common.CheckErr(t, err, true)
16501650
common.CheckQueryIteratorResult(ctx, t, itr, exprLimit.count, common.WithExpBatchSize(common.GenBatchSizes(exprLimit.count, batch)))

0 commit comments

Comments
 (0)