Skip to content

Commit

Permalink
add field check
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-HuWei committed Jul 10, 2024
1 parent e08b801 commit 6b4a0e6
Showing 1 changed file with 40 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
package org.apache.seatunnel.e2e.connector.v2.milvus; /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.seatunnel.e2e.connector.v2.milvus;

import org.apache.seatunnel.e2e.common.TestResource;
import org.apache.seatunnel.e2e.common.TestSuiteBase;
Expand All @@ -33,13 +35,16 @@
import com.alibaba.fastjson.JSONObject;
import io.milvus.client.MilvusServiceClient;
import io.milvus.grpc.DataType;
import io.milvus.grpc.DescribeCollectionResponse;
import io.milvus.grpc.FieldSchema;
import io.milvus.grpc.MutationResult;
import io.milvus.param.ConnectParam;
import io.milvus.param.IndexType;
import io.milvus.param.MetricType;
import io.milvus.param.R;
import io.milvus.param.RpcStatus;
import io.milvus.param.collection.CreateCollectionParam;
import io.milvus.param.collection.DescribeCollectionParam;
import io.milvus.param.collection.FieldType;
import io.milvus.param.collection.HasCollectionParam;
import io.milvus.param.collection.LoadCollectionParam;
Expand All @@ -53,6 +58,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Slf4j
Expand Down Expand Up @@ -160,7 +166,7 @@ private void initSourceData() {
milvusClient.loadCollection(
LoadCollectionParam.newBuilder().withCollectionName(COLLECTION_NAME).build());

System.out.println("Collection created");
log.info("Collection created");

// Insert 10 records into the collection
List<JSONObject> rows = new ArrayList<>();
Expand Down Expand Up @@ -204,5 +210,22 @@ public void testMilvus(TestContainer container) throws IOException, InterruptedE
.withCollectionName(COLLECTION_NAME)
.build());
Assertions.assertTrue(hasCollectionResponse.getData());

// check table fields
R<DescribeCollectionResponse> describeCollectionResponseR =
this.milvusClient.describeCollection(
DescribeCollectionParam.newBuilder()
.withDatabaseName("test")
.withCollectionName(COLLECTION_NAME)
.build());

DescribeCollectionResponse data = describeCollectionResponseR.getData();
List<String> fileds =
data.getSchema().getFieldsList().stream()
.map(FieldSchema::getName)
.collect(Collectors.toList());
Assertions.assertTrue(fileds.contains(ID_FIELD));
Assertions.assertTrue(fileds.contains(VECTOR_FIELD));
Assertions.assertTrue(fileds.contains(TITLE_FIELD));
}
}

0 comments on commit 6b4a0e6

Please sign in to comment.