github.com/lfch/etcd-io/tests/v3@v3.0.0-20221004140520-eac99acd3e9d/common/endpoint_test.go (about) 1 // Copyright 2022 The etcd Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package common 16 17 import ( 18 "context" 19 "testing" 20 "time" 21 22 clientv3 "github.com/lfch/etcd-io/client/v3" 23 "github.com/lfch/etcd-io/tests/v3/framework" 24 "github.com/lfch/etcd-io/tests/v3/framework/config" 25 "github.com/lfch/etcd-io/tests/v3/framework/testutils" 26 ) 27 28 func TestEndpointStatus(t *testing.T) { 29 testRunner.BeforeTest(t) 30 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 31 defer cancel() 32 clus := testRunner.NewCluster(ctx, t, config.ClusterConfig{ClusterSize: 3}) 33 defer clus.Close() 34 cc := framework.MustClient(clus.Client(clientv3.AuthConfig{})) 35 testutils.ExecuteUntil(ctx, t, func() { 36 _, err := cc.Status(ctx) 37 if err != nil { 38 t.Fatalf("get endpoint status error: %v", err) 39 } 40 }) 41 } 42 43 func TestEndpointHashKV(t *testing.T) { 44 testRunner.BeforeTest(t) 45 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 46 defer cancel() 47 clus := testRunner.NewCluster(ctx, t, config.ClusterConfig{ClusterSize: 3}) 48 defer clus.Close() 49 cc := framework.MustClient(clus.Client(clientv3.AuthConfig{})) 50 testutils.ExecuteUntil(ctx, t, func() { 51 _, err := cc.HashKV(ctx, 0) 52 if err != nil { 53 t.Fatalf("get endpoint hashkv error: %v", err) 54 } 55 }) 56 } 57 58 func TestEndpointHealth(t *testing.T) { 59 testRunner.BeforeTest(t) 60 ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) 61 defer cancel() 62 clus := testRunner.NewCluster(ctx, t, config.ClusterConfig{ClusterSize: 3}) 63 defer clus.Close() 64 cc := framework.MustClient(clus.Client(clientv3.AuthConfig{})) 65 testutils.ExecuteUntil(ctx, t, func() { 66 if err := cc.Health(ctx); err != nil { 67 t.Fatalf("get endpoint health error: %v", err) 68 } 69 }) 70 }