Search in sources :

Example 6 with MonitoredResource

use of com.google.api.services.monitoring.v3.model.MonitoredResource in project kork by spinnaker.

the class MonitoredResourceBuilderTest method testGceInstance.

@Test
public void testGceInstance() throws IOException {
    builder.setStackdriverProject("UNUSED");
    String instance = "MY INSTANCE";
    String zone = "us-central1-f";
    String zone_path = "path/to/" + zone;
    String project = "MY PROJECT";
    doReturn(instance).when(builder).getGoogleMetadataValue("instance/id");
    doReturn(zone_path).when(builder).getGoogleMetadataValue("instance/zone");
    doReturn(project).when(builder).getGoogleMetadataValue("project/project-id");
    Map<String, String> labels = new HashMap<String, String>();
    labels.put("instance_id", instance);
    labels.put("zone", zone);
    MonitoredResource resource = builder.build();
    Assert.assertEquals("gce_instance", resource.getType());
    Assert.assertEquals(labels, resource.getLabels());
}
Also used : HashMap(java.util.HashMap) MonitoredResource(com.google.api.services.monitoring.v3.model.MonitoredResource) Test(org.junit.Test)

Aggregations

MonitoredResource (com.google.api.services.monitoring.v3.model.MonitoredResource)5 HashMap (java.util.HashMap)4 IOException (java.io.IOException)3 Test (org.junit.Test)3 Point (com.google.api.services.monitoring.v3.model.Point)2 TimeSeries (com.google.api.services.monitoring.v3.model.TimeSeries)2 HttpResponseException (com.google.api.client.http.HttpResponseException)1 CreateTimeSeriesRequest (com.google.api.services.monitoring.v3.model.CreateTimeSeriesRequest)1 Metric (com.google.api.services.monitoring.v3.model.Metric)1 TimeInterval (com.google.api.services.monitoring.v3.model.TimeInterval)1 TypedValue (com.google.api.services.monitoring.v3.model.TypedValue)1 Date (java.util.Date)1