github.com/alibaba/ilogtail/pkg@v0.0.0-20250526110833-c53b480d046c/helper/platformmeta/mock.go (about) 1 // Copyright 2023 iLogtail 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 platformmeta 16 17 import "sync/atomic" 18 19 var MockManagerNum int64 20 21 type MockManager struct { 22 } 23 24 func (m *MockManager) StartCollect() { 25 26 } 27 28 func (m *MockManager) GetInstanceID() string { 29 return "id_xxx" 30 } 31 32 func (m *MockManager) GetInstanceImageID() string { 33 return "image_xxx" 34 } 35 36 func (m *MockManager) GetInstanceType() string { 37 return "type_xxx" 38 } 39 40 func (m *MockManager) GetInstanceRegion() string { 41 return "region_xxx" 42 } 43 44 func (m *MockManager) GetInstanceZone() string { 45 return "zone_xxx" 46 } 47 48 func (m *MockManager) GetInstanceName() string { 49 return "name_xxx" 50 } 51 52 func (m *MockManager) GetInstanceVpcID() string { 53 return "vpc_xxx" 54 } 55 56 func (m *MockManager) GetInstanceVswitchID() string { 57 return "vswitch_xxx" 58 } 59 60 func (m *MockManager) GetInstanceMaxNetEgress() int64 { 61 return atomic.LoadInt64(&MockManagerNum) * 10 62 } 63 64 func (m *MockManager) GetInstanceMaxNetIngress() int64 { 65 return atomic.LoadInt64(&MockManagerNum) 66 } 67 68 func (m *MockManager) GetInstanceTags() map[string]string { 69 return map[string]string{ 70 "tag_key": "tag_val", 71 } 72 } 73 74 func (m *MockManager) Ping() bool { 75 return false 76 } 77 78 func initMock() { 79 register[Mock] = &MockManager{} 80 }