2021-04-19 13:47:10 +08:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed 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.
|
|
|
|
|
2021-06-22 16:44:09 +08:00
|
|
|
package querycoord
|
2021-03-11 18:42:25 +08:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/require"
|
2021-07-13 14:16:00 +08:00
|
|
|
"go.etcd.io/etcd/clientv3"
|
|
|
|
|
|
|
|
etcdkv "github.com/milvus-io/milvus/internal/kv/etcd"
|
2021-03-11 18:42:25 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestReplica_Release(t *testing.T) {
|
2021-07-13 14:16:00 +08:00
|
|
|
etcdClient, err := clientv3.New(clientv3.Config{Endpoints: Params.EtcdEndpoints})
|
|
|
|
assert.Nil(t, err)
|
|
|
|
etcdKV := etcdkv.NewEtcdKV(etcdClient, Params.MetaRootPath)
|
|
|
|
meta, err := newMeta(etcdKV)
|
2021-06-19 11:45:09 +08:00
|
|
|
assert.Nil(t, err)
|
|
|
|
err = meta.addCollection(1, nil)
|
2021-03-11 18:42:25 +08:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
2021-06-15 12:41:40 +08:00
|
|
|
collections := meta.showCollections()
|
|
|
|
assert.Equal(t, 1, len(collections))
|
2021-03-11 18:42:25 +08:00
|
|
|
|
2021-06-15 12:41:40 +08:00
|
|
|
err = meta.addPartition(1, 100)
|
2021-03-11 18:42:25 +08:00
|
|
|
assert.NoError(t, err)
|
2021-06-15 12:41:40 +08:00
|
|
|
partitions, err := meta.showPartitions(1)
|
2021-03-11 18:42:25 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, 1, len(partitions))
|
|
|
|
|
2021-06-15 12:41:40 +08:00
|
|
|
meta.releasePartition(1, 100)
|
|
|
|
partitions, err = meta.showPartitions(1)
|
2021-03-11 18:42:25 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, 0, len(partitions))
|
2021-06-15 12:41:40 +08:00
|
|
|
meta.releasePartition(1, 100)
|
2021-03-11 18:42:25 +08:00
|
|
|
|
2021-06-15 12:41:40 +08:00
|
|
|
meta.releaseCollection(1)
|
|
|
|
collections = meta.showCollections()
|
|
|
|
assert.Equal(t, 0, len(collections))
|
|
|
|
meta.releaseCollection(1)
|
2021-03-11 18:42:25 +08:00
|
|
|
}
|