github.phpd.cn/cilium/cilium@v1.6.12/pkg/service/service_test.go (about) 1 // Copyright 2018 Authors of Cilium 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 // +build !privileged_tests 16 17 package service 18 19 import ( 20 "testing" 21 22 "github.com/cilium/cilium/pkg/kvstore" 23 24 . "gopkg.in/check.v1" 25 ) 26 27 // Hook up gocheck into the "go test" runner. 28 func Test(t *testing.T) { 29 TestingT(t) 30 } 31 32 type ServiceTestSuite struct{} 33 34 type ServiceEtcdSuite struct { 35 ServiceTestSuite 36 } 37 38 var _ = Suite(&ServiceEtcdSuite{}) 39 40 func (e *ServiceEtcdSuite) SetUpTest(c *C) { 41 EnableGlobalServiceID(true) 42 kvstore.SetupDummy("etcd") 43 kvstore.DeletePrefix(serviceKvstorePrefix) 44 } 45 46 func (e *ServiceEtcdSuite) TearDownTest(c *C) { 47 kvstore.DeletePrefix(serviceKvstorePrefix) 48 kvstore.Close() 49 } 50 51 type ServiceConsulSuite struct { 52 ServiceTestSuite 53 } 54 55 var _ = Suite(&ServiceConsulSuite{}) 56 57 func (e *ServiceConsulSuite) SetUpTest(c *C) { 58 EnableGlobalServiceID(true) 59 kvstore.SetupDummy("consul") 60 kvstore.DeletePrefix(serviceKvstorePrefix) 61 } 62 63 func (e *ServiceConsulSuite) TearDownTest(c *C) { 64 kvstore.DeletePrefix(serviceKvstorePrefix) 65 kvstore.Close() 66 } 67 68 type ServiceLocalSuite struct { 69 ServiceTestSuite 70 } 71 72 var _ = Suite(&ServiceLocalSuite{}) 73 74 func (e *ServiceLocalSuite) SetUpTest(c *C) { 75 EnableGlobalServiceID(false) 76 serviceIDAlloc.resetLocalID() 77 } 78 79 func (e *ServiceLocalSuite) TearDownTest(c *C) { 80 serviceIDAlloc.resetLocalID() 81 }