-
Notifications
You must be signed in to change notification settings - Fork 178
Expand file tree
/
Copy pathAzureContainersResourceProviderTest.java
More file actions
56 lines (47 loc) · 2.05 KB
/
AzureContainersResourceProviderTest.java
File metadata and controls
56 lines (47 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.contrib.azure.resource;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_INSTANCE_ID;
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME;
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_VERSION;
import static io.opentelemetry.semconv.incubating.CloudIncubatingAttributes.CLOUD_PLATFORM;
import static io.opentelemetry.semconv.incubating.CloudIncubatingAttributes.CLOUD_PROVIDER;
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.sdk.testing.assertj.AttributesAssert;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
class AzureContainersResourceProviderTest {
private static final String TEST_APP_NAME = "TEST_APP_NAME";
private static final String TEST_REPLICA_NAME = "TEST_REPLICA_NAME";
private static final String TEST_REVISION = "TEST_REVISION";
private static final ImmutableMap<String, String> DEFAULT_ENV_VARS =
ImmutableMap.of(
"CONTAINER_APP_NAME", TEST_APP_NAME,
"CONTAINER_APP_REPLICA_NAME", TEST_REPLICA_NAME,
"CONTAINER_APP_REVISION", TEST_REVISION);
@Test
void defaultValues() {
createResource(DEFAULT_ENV_VARS)
.containsEntry(CLOUD_PROVIDER, "azure")
.containsEntry(CLOUD_PLATFORM, "azure_container_apps")
.containsEntry(SERVICE_NAME, TEST_APP_NAME)
.containsEntry(SERVICE_INSTANCE_ID, TEST_REPLICA_NAME)
.containsEntry(SERVICE_VERSION, TEST_REVISION);
}
@Test
void isNotContainer() {
HashMap<String, String> map = new HashMap<>(DEFAULT_ENV_VARS);
map.remove("CONTAINER_APP_NAME");
createResource(map).isEmpty();
}
@NotNull
private static AttributesAssert createResource(Map<String, String> map) {
return assertThat(
new AzureContainersResourceProvider(map).createResource(null).getAttributes());
}
}