-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: ryjiang <[email protected]>
- Loading branch information
1 parent
d9c4aaf
commit 28d664a
Showing
6 changed files
with
163 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
import { MilvusClient, DataType, ErrorCode } from '../../milvus'; | ||
import { IP, GENERATE_NAME } from '../tools'; | ||
|
||
const milvusClient = new MilvusClient({ address: IP }); | ||
const COLLECTION_NAME = GENERATE_NAME(); | ||
const COLLECTION_NAME2 = GENERATE_NAME(); | ||
const dbParam = { | ||
db_name: 'ClusteringKey', | ||
}; | ||
|
||
describe(`Clustering key API`, () => { | ||
beforeAll(async () => { | ||
await milvusClient.createDatabase(dbParam); | ||
await milvusClient.use(dbParam); | ||
}); | ||
|
||
afterAll(async () => { | ||
await milvusClient.dropCollection({ | ||
collection_name: COLLECTION_NAME, | ||
}); | ||
await milvusClient.dropCollection({ | ||
collection_name: COLLECTION_NAME2, | ||
}); | ||
await milvusClient.dropDatabase(dbParam); | ||
}); | ||
|
||
it(`Create Collection with schema should successfully`, async () => { | ||
const schema = [ | ||
{ | ||
name: 'vector', | ||
description: 'Vector field', | ||
data_type: DataType.FloatVector, | ||
dim: Number(4), | ||
}, | ||
{ | ||
name: 'id', | ||
description: 'ID field', | ||
data_type: DataType.Int64, | ||
is_primary_key: true, | ||
autoID: true, | ||
}, | ||
{ | ||
name: 'varChar', | ||
description: 'VarChar field', | ||
data_type: DataType.VarChar, | ||
max_length: 128, | ||
is_partition_key: false, | ||
is_clustering_key: true, | ||
}, | ||
{ | ||
name: 'array', | ||
description: 'array field', | ||
data_type: DataType.Array, | ||
element_type: DataType.VarChar, | ||
max_capacity: 128, | ||
max_length: 128, | ||
is_partition_key: false, | ||
}, | ||
]; | ||
const res = await milvusClient.createCollection({ | ||
collection_name: COLLECTION_NAME, | ||
fields: schema, | ||
}); | ||
expect(res.error_code).toEqual(ErrorCode.SUCCESS); | ||
|
||
// describe | ||
const desc = await milvusClient.describeCollection({ | ||
collection_name: COLLECTION_NAME, | ||
}); | ||
|
||
// test clustering key | ||
let found = 0; | ||
desc.schema.fields.forEach(field => { | ||
if (field.is_clustering_key) { | ||
found++; | ||
expect(field.name).toEqual('varChar'); | ||
} | ||
}); | ||
|
||
expect(found).toEqual(1); | ||
}); | ||
|
||
it(`Create Collection should be successful with clusteringkey`, async () => { | ||
const schema = [ | ||
{ | ||
name: 'vector', | ||
description: 'Vector field', | ||
data_type: DataType.FloatVector, | ||
dim: Number(4), | ||
}, | ||
{ | ||
name: 'id', | ||
description: 'ID field', | ||
data_type: DataType.Int64, | ||
is_primary_key: true, | ||
autoID: true, | ||
}, | ||
{ | ||
name: 'varChar', | ||
description: 'VarChar field', | ||
data_type: DataType.VarChar, | ||
max_length: 128, | ||
is_partition_key: false, | ||
is_clustering_key: false, | ||
}, | ||
{ | ||
name: 'array', | ||
description: 'array field', | ||
data_type: DataType.Array, | ||
element_type: DataType.VarChar, | ||
max_capacity: 128, | ||
max_length: 128, | ||
is_partition_key: false, | ||
}, | ||
]; | ||
const res = await milvusClient.createCollection({ | ||
collection_name: COLLECTION_NAME2, | ||
fields: schema, | ||
clustring_key_field: 'varChar', | ||
}); | ||
expect(res.error_code).toEqual(ErrorCode.SUCCESS); | ||
|
||
// describe | ||
const desc = await milvusClient.describeCollection({ | ||
collection_name: COLLECTION_NAME2, | ||
}); | ||
|
||
// test clustering key | ||
let found = 0; | ||
desc.schema.fields.forEach(field => { | ||
if (field.is_clustering_key) { | ||
found++; | ||
expect(field.name).toEqual('varChar'); | ||
} | ||
}); | ||
|
||
expect(found).toEqual(1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters