@@ -171,60 +171,6 @@ def test_aws_monitored_resource(self, aws_metadata_mock):
171171 {'mock_label_key' : 'mock_label_value' }, resource .get_labels ())
172172 self .assertDictContainsSubset (mocked_labels , resource .get_labels ())
173173
174- def test_gke_environment (self ):
175- patch = mock .patch .dict (os .environ ,
176- {'KUBERNETES_SERVICE_HOST' : '127.0.0.1' })
177-
178- with no_oc_env ():
179- with patch :
180- mr = monitored_resource .get_instance ()
181- self .assertIsNotNone (mr )
182- self .assertEqual (mr .get_type (), "gke_container" )
183-
184- with mock_oc_env ():
185- mr = monitored_resource .get_instance ()
186- self .assertEqual (mr .get_type (), 'mock_resource_type' )
187- self .assertDictContainsSubset (
188- {'mock_label_key' : 'mock_label_value' }, mr .get_labels ())
189-
190- def test_gce_environment (self ):
191- patch = mock .patch (
192- 'opencensus.common.monitored_resource.'
193- 'gcp_metadata_config.GcpMetadataConfig.'
194- 'is_running_on_gcp' ,
195- return_value = True )
196- with no_oc_env ():
197- with patch :
198- mr = monitored_resource .get_instance ()
199-
200- self .assertIsNotNone (mr )
201- self .assertEqual (mr .get_type (), "gce_instance" )
202-
203- with mock_oc_env ():
204- mr = monitored_resource .get_instance ()
205- self .assertEqual (mr .get_type (), 'mock_resource_type' )
206- self .assertDictContainsSubset (
207- {'mock_label_key' : 'mock_label_value' }, mr .get_labels ())
208-
209- @mock .patch ('opencensus.common.monitored_resource.'
210- 'gcp_metadata_config.GcpMetadataConfig.is_running_on_gcp' ,
211- return_value = False )
212- @mock .patch ('opencensus.common.monitored_resource.'
213- 'aws_identity_doc_utils.AwsIdentityDocumentUtils.'
214- 'is_running_on_aws' ,
215- return_value = True )
216- def test_aws_environment (self , aws_util_mock , gcp_metadata_mock ):
217- with no_oc_env ():
218- mr = monitored_resource .get_instance ()
219- self .assertIsNotNone (mr )
220- self .assertEqual (mr .get_type (), "aws_ec2_instance" )
221-
222- with mock_oc_env ():
223- mr = monitored_resource .get_instance ()
224- self .assertEqual (mr .get_type (), 'mock_resource_type' )
225- self .assertDictContainsSubset (
226- {'mock_label_key' : 'mock_label_value' }, mr .get_labels ())
227-
228174 @mock .patch ('opencensus.common.monitored_resource.'
229175 'gcp_metadata_config.GcpMetadataConfig.is_running_on_gcp' ,
230176 return_value = False )
0 commit comments