Repository: milvus-io/milvus-sdk-go
Pull request #124 (2021-07-12 07:10:54)

Add entity package unit tests
Add entity package unit tests
Update gen.go to generate unit tests

See also: #114 

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>

sre-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/124#" title="Author self-approved">congqixia</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)~~ [congqixia]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
sunby: /lgtm
/approve
sre-ci-robot: @sunby: changing LGTM is restricted to collaborators

<details>

In response to [this](https://github.com/milvus-io/milvus-sdk-go/pull/124#issuecomment-878034317):

>/lgtm
>/approve


Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
</details>
sre-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/124#" title="Author self-approved">congqixia</a>*, *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/124#issuecomment-878034317" title="Approved">sunby</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)~~ [congqixia]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
sunby: /lgtm
/approve
sre-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/124#" title="Author self-approved">congqixia</a>*, *<a href="https://github.com/milvus-io/milvus-sdk-go/pull/124#issuecomment-878038371" title="Approved">sunby</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=milvus-io%2Fmilvus-sdk-go).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/milvus-io/milvus-sdk-go/blob/master/OWNERS)~~ [congqixia,sunby]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->

Patch:
diff --git a/entity/columns_binaryvector.go b/entity/columns_binaryvector.go
index f2a9804..2a7d2bf 100755
--- a/entity/columns_binaryvector.go
+++ b/entity/columns_binaryvector.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
diff --git a/entity/columns_bool.go b/entity/columns_bool.go
index 0f946d8..3538698 100755
--- a/entity/columns_bool.go
+++ b/entity/columns_bool.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
@@ -35,9 +35,9 @@ func (c *ColumnBool) FieldData() *schema.FieldData {
 	}
 	fd.Field = &schema.FieldData_Scalars{
 		Scalars: &schema.ScalarField{
-			Data: &schema.ScalarField_IntData{
-				IntData: &schema.IntArray{
-					Data: []int32{},
+			Data: &schema.ScalarField_BoolData{
+				BoolData: &schema.BoolArray{
+					Data: []bool{},
 				},
 			},
 		},
diff --git a/entity/columns_double.go b/entity/columns_double.go
index 69090d5..acbb732 100755
--- a/entity/columns_double.go
+++ b/entity/columns_double.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
@@ -35,9 +35,9 @@ func (c *ColumnDouble) FieldData() *schema.FieldData {
 	}
 	fd.Field = &schema.FieldData_Scalars{
 		Scalars: &schema.ScalarField{
-			Data: &schema.ScalarField_IntData{
-				IntData: &schema.IntArray{
-					Data: []int32{},
+			Data: &schema.ScalarField_DoubleData{
+				DoubleData: &schema.DoubleArray{
+					Data: []float64{},
 				},
 			},
 		},
diff --git a/entity/columns_float.go b/entity/columns_float.go
index 8d39cd2..08fa69c 100755
--- a/entity/columns_float.go
+++ b/entity/columns_float.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
@@ -35,9 +35,9 @@ func (c *ColumnFloat) FieldData() *schema.FieldData {
 	}
 	fd.Field = &schema.FieldData_Scalars{
 		Scalars: &schema.ScalarField{
-			Data: &schema.ScalarField_IntData{
-				IntData: &schema.IntArray{
-					Data: []int32{},
+			Data: &schema.ScalarField_FloatData{
+				FloatData: &schema.FloatArray{
+					Data: []float32{},
 				},
 			},
 		},
diff --git a/entity/columns_floatvector.go b/entity/columns_floatvector.go
index 6bf714c..9cc815a 100755
--- a/entity/columns_floatvector.go
+++ b/entity/columns_floatvector.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
diff --git a/entity/columns_int16.go b/entity/columns_int16.go
index 5cd2e70..55fac40 100755
--- a/entity/columns_int16.go
+++ b/entity/columns_int16.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
diff --git a/entity/columns_int32.go b/entity/columns_int32.go
index 3d2d0a6..69c148e 100755
--- a/entity/columns_int32.go
+++ b/entity/columns_int32.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
diff --git a/entity/columns_int64.go b/entity/columns_int64.go
index 3d61bd8..2410a6c 100755
--- a/entity/columns_int64.go
+++ b/entity/columns_int64.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
@@ -35,9 +35,9 @@ func (c *ColumnInt64) FieldData() *schema.FieldData {
 	}
 	fd.Field = &schema.FieldData_Scalars{
 		Scalars: &schema.ScalarField{
-			Data: &schema.ScalarField_IntData{
-				IntData: &schema.IntArray{
-					Data: []int32{},
+			Data: &schema.ScalarField_LongData{
+				LongData: &schema.LongArray{
+					Data: []int64{},
 				},
 			},
 		},
diff --git a/entity/columns_int8.go b/entity/columns_int8.go
index 0593af1..288c916 100755
--- a/entity/columns_int8.go
+++ b/entity/columns_int8.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
diff --git a/entity/columns_string.go b/entity/columns_string.go
index 139ed74..a2ee9e3 100755
--- a/entity/columns_string.go
+++ b/entity/columns_string.go
@@ -1,5 +1,5 @@
 // Code generated by go generate; DO NOT EDIT
-// This file is generated by go genrated at 2021-07-08 10:54:30.984859088 &#43;0800 CST m=&#43;0.002222031
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
 
 //Package entity defines entities used in sdk
 package entity 
@@ -35,9 +35,9 @@ func (c *ColumnString) FieldData() *schema.FieldData {
 	}
 	fd.Field = &schema.FieldData_Scalars{
 		Scalars: &schema.ScalarField{
-			Data: &schema.ScalarField_IntData{
-				IntData: &schema.IntArray{
-					Data: []int32{},
+			Data: &schema.ScalarField_StringData{
+				StringData: &schema.StringArray{
+					Data: []string{},
 				},
 			},
 		},
diff --git a/entity/gen/gen.go b/entity/gen/gen.go
index 8424662..97e5d81 100644
--- a/entity/gen/gen.go
+++ b/entity/gen/gen.go
@@ -157,6 +157,134 @@ func NewColumn{{.TypeName}}(name string, dim int, values []{{.TypeDef}}) *Column
 }
 `))
 
+var scalarColumnTestTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at {{ .Timestamp }}
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumn{{.TypeName}}(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_{{.TypeName}}_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]{{.TypeDef}}, columnLen)
+	column := NewColumn{{.TypeName}}(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldType{{.TypeName}}
+		assert.Equal(t, "{{.TypeName}}", ft.Name())
+		assert.Equal(t, "{{.TypeDef}}", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "{{.PbName}}", pbName)
+		assert.Equal(t, "{{.PbType}}", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldType{{.TypeName}}, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldData{{.TypeName}}Column(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_{{.TypeName}}_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_{{.TypeName}},
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_{{.PbName}}Data{
+					{{.PbName}}Data: &schema.{{.PbName}}Array{
+						Data: make([]{{.PbType}}, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldType{{.TypeName}}, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
+`))
+var vectorColumnTestTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at {{ .Timestamp }}
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestColumn{{.TypeName}}(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_{{.TypeName}}_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+	dim := ([]int{8, 32, 64, 128})[rand.Intn(4)]
+
+	v := make([]{{.TypeDef}}, columnLen)
+	column := NewColumn{{.TypeName}}(columnName,dim, v)
+	
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldType{{.TypeName}}
+		assert.Equal(t, "{{.TypeName}}", ft.Name())
+		assert.Equal(t, "{{.TypeDef}}", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "{{.PbName}}", pbName)
+		assert.Equal(t, "{{.PbType}}", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldType{{.TypeName}}, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+		assert.Equal(t, dim, column.Dim())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+`))
+
 func main() {
 	scalarFieldTypes := []entity.FieldType{
 		entity.FieldTypeBool,
@@ -173,18 +301,9 @@ func main() {
 		entity.FieldTypeFloatVector,
 	}
 	now := time.Now()
-	fn := func(types []entity.FieldType, tmpl *template.Template, pf func(entity.FieldType) interface{}) {
-		for _, ft := range types {
-			f, err := os.OpenFile(fmt.Sprintf("columns_%s.go", strings.ToLower(ft.Name())), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
-			if err != nil {
-				fmt.Println(err.Error())
-			}
-			defer f.Close()
 
-			tmpl.Execute(f, pf(ft))
-		}
-	}
-	fn(scalarFieldTypes, scalarColumnTemplate, func(ft entity.FieldType) interface{} {
+	pf := func(ft entity.FieldType) interface{} {
+		pbName, pbType := ft.PbFieldType()
 		return struct {
 			Timestamp time.Time
 			TypeName  string
@@ -195,19 +314,35 @@ func main() {
 			Timestamp: now,
 			TypeName:  ft.Name(),
 			TypeDef:   ft.String(),
-			PbName:    "Int",
-			PbType:    "int32",
+			PbName:    pbName,
+			PbType:    pbType,
 		}
-	})
-	fn(vectorFieldTypes, vectorColumnTemplate, func(ft entity.FieldType) interface{} {
-		return struct {
-			Timestamp time.Time
-			TypeName  string
-			TypeDef   string
-		}{
-			Timestamp: now,
-			TypeName:  ft.Name(),
-			TypeDef:   ft.String(),
+	}
+	fn := func(types []entity.FieldType, tmpl *template.Template, pf func(entity.FieldType) interface{}) {
+		for _, ft := range types {
+			f, err := os.OpenFile(fmt.Sprintf("columns_%s.go", strings.ToLower(ft.Name())), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
+			if err != nil {
+				fmt.Println(err.Error())
+				continue
+			}
+			defer f.Close()
+
+			tmpl.Execute(f, pf(ft))
 		}
-	})
+	}
+	fnTest := func(types []entity.FieldType, tmpl *template.Template, pf func(entity.FieldType) interface{}) {
+		for _, ft := range types {
+			f, err := os.OpenFile(fmt.Sprintf("columns_%s_test.go", strings.ToLower(ft.Name())), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
+			if err != nil {
+				fmt.Println(err.Error())
+				continue
+			}
+			defer f.Close()
+			tmpl.Execute(f, pf(ft))
+		}
+	}
+	fn(scalarFieldTypes, scalarColumnTemplate, pf)
+	fn(vectorFieldTypes, vectorColumnTemplate, pf)
+	fnTest(scalarFieldTypes, scalarColumnTestTemplate, pf)
+	fnTest(vectorFieldTypes, vectorColumnTestTemplate, pf)
 }
diff --git a/entity/index.go b/entity/index.go
index c290277..ce555c5 100644
--- a/entity/index.go
+++ b/entity/index.go
@@ -93,9 +93,9 @@ func (f flatIndex) Params() map[string]string {
 	}
 }
 
-func NewFlatIndex(m MetricType) Index {
+func NewFlatIndex(name string, m MetricType) Index {
 	return flatIndex{
-		baseIndex: baseIndex{it: Flat},
+		baseIndex: baseIndex{it: Flat, name: name},
 		m:         m,
 	}
 }


Test patch:
diff --git a/client/client_grpc_dd_test.go b/client/client_grpc_dd_test.go
index 15fd847..ada3bcb 100644
--- a/client/client_grpc_dd_test.go
+++ b/client/client_grpc_dd_test.go
@@ -56,7 +56,7 @@ func TestGrpcClientNil(t *testing.T) {
 			case reflect.Interface:
 				idxType := reflect.TypeOf((*entity.Index)(nil)).Elem()
 				if inT.Implements(idxType) {
-					ins = append(ins, reflect.ValueOf(entity.NewFlatIndex(entity.L2)))
+					ins = append(ins, reflect.ValueOf(entity.NewFlatIndex("flat_index", entity.L2)))
 				}
 			default:
 				ins = append(ins, reflect.Zero(inT))
diff --git a/entity/columns_binaryvector_test.go b/entity/columns_binaryvector_test.go
new file mode 100755
index 0000000..3fd8631
--- /dev/null
+++ b/entity/columns_binaryvector_test.go
@@ -0,0 +1,46 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestColumnBinaryVector(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_BinaryVector_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+	dim := ([]int{8, 32, 64, 128})[rand.Intn(4)]
+
+	v := make([][]byte, columnLen)
+	column := NewColumnBinaryVector(columnName,dim, v)
+	
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeBinaryVector
+		assert.Equal(t, "BinaryVector", ft.Name())
+		assert.Equal(t, "[]byte", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "[]byte", pbName)
+		assert.Equal(t, "", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeBinaryVector, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+		assert.Equal(t, dim, column.Dim())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
diff --git a/entity/columns_bool_test.go b/entity/columns_bool_test.go
new file mode 100755
index 0000000..bfe267a
--- /dev/null
+++ b/entity/columns_bool_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnBool(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_Bool_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]bool, columnLen)
+	column := NewColumnBool(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeBool
+		assert.Equal(t, "Bool", ft.Name())
+		assert.Equal(t, "bool", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "Bool", pbName)
+		assert.Equal(t, "bool", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeBool, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataBoolColumn(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_Bool_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_Bool,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_BoolData{
+					BoolData: &schema.BoolArray{
+						Data: make([]bool, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeBool, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_double_test.go b/entity/columns_double_test.go
new file mode 100755
index 0000000..56852d7
--- /dev/null
+++ b/entity/columns_double_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnDouble(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_Double_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]float64, columnLen)
+	column := NewColumnDouble(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeDouble
+		assert.Equal(t, "Double", ft.Name())
+		assert.Equal(t, "float64", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "Double", pbName)
+		assert.Equal(t, "float64", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeDouble, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataDoubleColumn(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_Double_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_Double,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_DoubleData{
+					DoubleData: &schema.DoubleArray{
+						Data: make([]float64, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeDouble, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_float_test.go b/entity/columns_float_test.go
new file mode 100755
index 0000000..48e7a93
--- /dev/null
+++ b/entity/columns_float_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnFloat(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_Float_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]float32, columnLen)
+	column := NewColumnFloat(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeFloat
+		assert.Equal(t, "Float", ft.Name())
+		assert.Equal(t, "float32", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "Float", pbName)
+		assert.Equal(t, "float32", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeFloat, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataFloatColumn(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_Float_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_Float,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_FloatData{
+					FloatData: &schema.FloatArray{
+						Data: make([]float32, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeFloat, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_floatvector_test.go b/entity/columns_floatvector_test.go
new file mode 100755
index 0000000..5296fae
--- /dev/null
+++ b/entity/columns_floatvector_test.go
@@ -0,0 +1,46 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestColumnFloatVector(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_FloatVector_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+	dim := ([]int{8, 32, 64, 128})[rand.Intn(4)]
+
+	v := make([][]float32, columnLen)
+	column := NewColumnFloatVector(columnName,dim, v)
+	
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeFloatVector
+		assert.Equal(t, "FloatVector", ft.Name())
+		assert.Equal(t, "[]float32", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "[]float32", pbName)
+		assert.Equal(t, "", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeFloatVector, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+		assert.Equal(t, dim, column.Dim())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
diff --git a/entity/columns_int16_test.go b/entity/columns_int16_test.go
new file mode 100755
index 0000000..b2dd548
--- /dev/null
+++ b/entity/columns_int16_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnInt16(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_Int16_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]int16, columnLen)
+	column := NewColumnInt16(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeInt16
+		assert.Equal(t, "Int16", ft.Name())
+		assert.Equal(t, "int16", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "Int", pbName)
+		assert.Equal(t, "int32", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeInt16, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataInt16Column(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_Int16_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_Int16,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_IntData{
+					IntData: &schema.IntArray{
+						Data: make([]int32, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeInt16, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_int32_test.go b/entity/columns_int32_test.go
new file mode 100755
index 0000000..4a1c027
--- /dev/null
+++ b/entity/columns_int32_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnInt32(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_Int32_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]int32, columnLen)
+	column := NewColumnInt32(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeInt32
+		assert.Equal(t, "Int32", ft.Name())
+		assert.Equal(t, "int32", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "Int", pbName)
+		assert.Equal(t, "int32", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeInt32, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataInt32Column(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_Int32_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_Int32,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_IntData{
+					IntData: &schema.IntArray{
+						Data: make([]int32, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeInt32, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_int64_test.go b/entity/columns_int64_test.go
new file mode 100755
index 0000000..0ce923a
--- /dev/null
+++ b/entity/columns_int64_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnInt64(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_Int64_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]int64, columnLen)
+	column := NewColumnInt64(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeInt64
+		assert.Equal(t, "Int64", ft.Name())
+		assert.Equal(t, "int64", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "Long", pbName)
+		assert.Equal(t, "int64", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeInt64, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataInt64Column(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_Int64_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_Int64,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_LongData{
+					LongData: &schema.LongArray{
+						Data: make([]int64, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeInt64, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_int8_test.go b/entity/columns_int8_test.go
new file mode 100755
index 0000000..68b7cbf
--- /dev/null
+++ b/entity/columns_int8_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnInt8(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_Int8_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]int8, columnLen)
+	column := NewColumnInt8(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeInt8
+		assert.Equal(t, "Int8", ft.Name())
+		assert.Equal(t, "int8", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "Int", pbName)
+		assert.Equal(t, "int32", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeInt8, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataInt8Column(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_Int8_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_Int8,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_IntData{
+					IntData: &schema.IntArray{
+						Data: make([]int32, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeInt8, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_string_test.go b/entity/columns_string_test.go
new file mode 100755
index 0000000..7259409
--- /dev/null
+++ b/entity/columns_string_test.go
@@ -0,0 +1,79 @@
+// Code generated by go generate; DO NOT EDIT
+// This file is generated by go genrated at 2021-07-12 12:48:54.240744206 &#43;0800 CST m=&#43;0.002833978
+
+//Package entity defines entities used in sdk
+package entity 
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+)
+
+func TestColumnString(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	columnName := fmt.Sprintf("column_String_%d", rand.Int())
+	columnLen := 8 + rand.Intn(10)
+
+	v := make([]string, columnLen)
+	column := NewColumnString(columnName, v)
+
+	t.Run("test meta", func(t *testing.T) {
+		ft := FieldTypeString
+		assert.Equal(t, "String", ft.Name())
+		assert.Equal(t, "string", ft.String())
+		pbName, pbType := ft.PbFieldType()
+		assert.Equal(t, "String", pbName)
+		assert.Equal(t, "string", pbType)
+	})
+
+	t.Run("test column attribute", func(t *testing.T) {
+		assert.Equal(t, columnName, column.Name())
+		assert.Equal(t, FieldTypeString, column.Type())
+		assert.Equal(t, columnLen, column.Len())
+	})
+
+	t.Run("test column field data", func(t *testing.T) {
+		fd := column.FieldData()
+		assert.NotNil(t, fd)
+		assert.Equal(t, fd.GetFieldName(), columnName)
+	})
+}
+
+func TestFieldDataStringColumn(t *testing.T) {
+	len := rand.Intn(10) + 8
+	name := fmt.Sprintf("fd_String_%d", rand.Int())
+	fd := &schema.FieldData{
+		Type: schema.DataType_String,
+		FieldName: name,
+	}
+
+	t.Run("normal usage", func(t *testing.T) {
+		fd.Field = &schema.FieldData_Scalars{
+			Scalars: &schema.ScalarField{
+				Data: &schema.ScalarField_StringData{
+					StringData: &schema.StringArray{
+						Data: make([]string, len),
+					},
+				},
+			},
+		}
+		column, err:= FieldDataColumn(fd, 0, len)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+ 
+		assert.Equal(t, name, column.Name())
+		assert.Equal(t, len, column.Len())
+		assert.Equal(t, FieldTypeString, column.Type())
+	})
+
+	t.Run("nil data", func(t *testing.T) {
+		fd.Field = nil
+		_, err := FieldDataColumn(fd, 0, len)
+		assert.NotNil(t, err)
+	})
+}
diff --git a/entity/columns_test.go b/entity/columns_test.go
new file mode 100644
index 0000000..df489fb
--- /dev/null
+++ b/entity/columns_test.go
@@ -0,0 +1,97 @@
+package entity
+
+import (
+	"math/rand"
+	"strconv"
+	"testing"
+	"time"
+
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/schema"
+	"github.com/stretchr/testify/assert"
+)
+
+func TestVectors(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	dim := rand.Intn(127) + 1
+
+	t.Run("test float vector", func(t *testing.T) {
+		raw := make([]float32, dim)
+		for i := 0; i < dim; i++ {
+			raw[i] = rand.Float32()
+		}
+
+		fv := FloatVector(raw)
+
+		assert.Equal(t, dim, fv.Dim())
+		assert.Equal(t, dim*4, len(fv.Serialize()))
+	})
+
+	t.Run("test binary vector", func(t *testing.T) {
+		raw := make([]byte, dim)
+		_, err := rand.Read(raw)
+		assert.Nil(t, err)
+
+		bv := BinaryVector(raw)
+
+		assert.Equal(t, dim*8, bv.Dim())
+		assert.ElementsMatch(t, raw, bv.Serialize())
+	})
+}
+
+func TestIDColumns(t *testing.T) {
+	dataLen := rand.Intn(100) + 1
+	base := rand.Intn(5000) // id start point
+
+	t.Run("nil id", func(t *testing.T) {
+		_, err := IDColumns(nil, 0, -1)
+		assert.NotNil(t, err)
+		idField := &schema.IDs{}
+		_, err = IDColumns(idField, 0, -1)
+		assert.NotNil(t, err)
+	})
+
+	t.Run("int ids", func(t *testing.T) {
+		ids := make([]int64, 0, dataLen)
+		for i := 0; i < dataLen; i++ {
+			ids = append(ids, int64(i+base))
+		}
+		idField := &schema.IDs{
+			IdField: &schema.IDs_IntId{
+				IntId: &schema.LongArray{
+					Data: ids,
+				},
+			},
+		}
+		column, err := IDColumns(idField, 0, dataLen)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+		assert.Equal(t, dataLen, column.Len())
+
+		column, err = IDColumns(idField, 0, -1) // test -1 method
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+		assert.Equal(t, dataLen, column.Len())
+	})
+	t.Run("string ids", func(t *testing.T) {
+		ids := make([]string, 0, dataLen)
+		for i := 0; i < dataLen; i++ {
+			ids = append(ids, strconv.FormatInt(int64(i+base), 10))
+		}
+		idField := &schema.IDs{
+			IdField: &schema.IDs_StrId{
+				StrId: &schema.StringArray{
+					Data: ids,
+				},
+			},
+		}
+		column, err := IDColumns(idField, 0, dataLen)
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+		assert.Equal(t, dataLen, column.Len())
+
+		column, err = IDColumns(idField, 0, -1) // test -1 method
+		assert.Nil(t, err)
+		assert.NotNil(t, column)
+		assert.Equal(t, dataLen, column.Len())
+	})
+}
diff --git a/entity/index_test.go b/entity/index_test.go
new file mode 100644
index 0000000..406fb0b
--- /dev/null
+++ b/entity/index_test.go
@@ -0,0 +1,29 @@
+package entity
+
+import (
+	"fmt"
+	"math/rand"
+	"testing"
+	"time"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestGenericIndex(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	name := fmt.Sprintf("generic_index_%d", rand.Int())
+	gi := NewGenericIndex(name, IvfFlat, map[string]string{
+		tMetricType: string(IP),
+	})
+	assert.Equal(t, name, gi.Name())
+	assert.EqualValues(t, IvfFlat, gi.Params()[tIndexType])
+}
+
+func TestFlatIndex(t *testing.T) {
+	rand.Seed(time.Now().UnixNano())
+	name := fmt.Sprintf("flat_index_%d", rand.Int())
+	fi := NewFlatIndex(name, L2)
+	assert.Equal(t, name, fi.Name())
+	assert.EqualValues(t, Flat, fi.Params()[tIndexType])
+	assert.EqualValues(t, L2, fi.Params()[tMetricType])
+}
diff --git a/entity/schema_test.go b/entity/schema_test.go
new file mode 100644
index 0000000..9c838a7
--- /dev/null
+++ b/entity/schema_test.go
@@ -0,0 +1,72 @@
+package entity
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+)
+
+func TestFieldSchema(t *testing.T) {
+	fields := []*Field{
+		{
+			Name:        "int_field",
+			DataType:    FieldTypeInt64,
+			AutoID:      true,
+			PrimaryKey:  true,
+			Description: "int_field desc",
+			TypeParams:  map[string]string{},
+		},
+		{
+			Name:        "string_field",
+			DataType:    FieldTypeString,
+			AutoID:      false,
+			PrimaryKey:  true,
+			Description: "false_field desc",
+			TypeParams:  map[string]string{"max_len": "32"}, // not applied, just testing value
+		},
+	}
+
+	for _, field := range fields {
+		fieldSchema := field.ProtoMessage()
+		assert.Equal(t, field.ID, fieldSchema.GetFieldID())
+		assert.Equal(t, field.Name, fieldSchema.GetName())
+		assert.EqualValues(t, field.DataType, fieldSchema.GetDataType())
+		assert.Equal(t, field.AutoID, fieldSchema.GetAutoID())
+		assert.Equal(t, field.PrimaryKey, fieldSchema.GetIsPrimaryKey())
+		assert.Equal(t, field.Description, fieldSchema.GetDescription())
+		assert.Equal(t, field.TypeParams, KvPairsMap(fieldSchema.GetTypeParams()))
+		// marshal & unmarshal, still equals
+		nf := &Field{}
+		nf = nf.ReadProto(fieldSchema)
+		assert.Equal(t, field.ID, nf.ID)
+		assert.Equal(t, field.Name, nf.Name)
+		assert.EqualValues(t, field.DataType, nf.DataType)
+		assert.Equal(t, field.AutoID, nf.AutoID)
+		assert.Equal(t, field.PrimaryKey, nf.PrimaryKey)
+		assert.Equal(t, field.Description, nf.Description)
+		assert.Equal(t, field.TypeParams, nf.TypeParams)
+	}
+}
+
+func TestSchema(t *testing.T) {
+	schemas := []*Schema{
+		{
+			CollectionName: "test_collection_1",
+			AutoID:         false,
+			Description:    "test_collection_1 decription",
+		},
+	}
+	for _, sch := range schemas {
+		p := sch.ProtoMessage()
+		assert.Equal(t, sch.CollectionName, p.GetName())
+		assert.Equal(t, sch.AutoID, p.GetAutoID())
+		assert.Equal(t, sch.Description, p.GetDescription())
+
+		nsch := &Schema{}
+		nsch = nsch.ReadProto(p)
+
+		assert.Equal(t, sch.CollectionName, nsch.CollectionName)
+		assert.Equal(t, sch.AutoID, nsch.AutoID)
+		assert.Equal(t, sch.Description, nsch.Description)
+	}
+}
diff --git a/entity/segment_test.go b/entity/segment_test.go
new file mode 100644
index 0000000..0f08627
--- /dev/null
+++ b/entity/segment_test.go
@@ -0,0 +1,19 @@
+package entity
+
+import (
+	"testing"
+
+	"github.com/milvus-io/milvus-sdk-go/internal/proto/common"
+	"github.com/stretchr/testify/assert"
+)
+
+func TestSegmentFlushed(t *testing.T) {
+	segment := &Segment{}
+	assert.False(t, segment.Flushed())
+	segment.State = common.SegmentState_Growing
+	assert.False(t, segment.Flushed())
+	segment.State = common.SegmentState_Flushing
+	assert.False(t, segment.Flushed())
+	segment.State = common.SegmentState_Flushed
+	assert.True(t, segment.Flushed())
+}
diff --git a/scripts/run_go_unittest.sh b/scripts/run_go_unittest.sh
index cba9bb0..5909a71 100755
--- a/scripts/run_go_unittest.sh
+++ b/scripts/run_go_unittest.sh
@@ -14,3 +14,4 @@ MILVUS_SDK_DIR="${ROOT_DIR}"
 echo $MILVUS_SDK_DIR
 
 go test -race -cover "${MILVUS_SDK_DIR}/client/..." -failfast -v
+go test -race -cover "${MILVUS_SDK_DIR}/entity/..." -failfast -v