-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gh-116 Use Hazelcast 2.4 for compilation, include Hazelcast2CacheMetr…
…icsTest
- Loading branch information
Daan Kerkhofs
committed
Jul 12, 2021
1 parent
8151a67
commit 1397456
Showing
3 changed files
with
48 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...form/src/test/java/eu/xenit/alfred/telemetry/binder/cache/Hazelcast2CacheMetricsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package eu.xenit.alfred.telemetry.binder.cache; | ||
|
||
import static org.awaitility.Awaitility.await; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.hamcrest.Matchers.nullValue; | ||
|
||
import com.hazelcast.config.Config; | ||
import com.hazelcast.core.Hazelcast; | ||
import com.hazelcast.core.HazelcastInstance; | ||
import com.hazelcast.core.IMap; | ||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry; | ||
import java.time.Duration; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class Hazelcast2CacheMetricsTest { | ||
|
||
@Test | ||
void testBasicPutAndGetMetrics() { | ||
SimpleMeterRegistry meterRegistry = new SimpleMeterRegistry(); | ||
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(new Config()); | ||
IMap<String, String> cache = hazelcastInstance.getMap(this.getClass().getSimpleName()); | ||
|
||
Hazelcast2CacheMetrics.monitor(meterRegistry, cache); | ||
cache.put("foo", "bar"); | ||
|
||
assertThat(cache.get("foo"), is("bar")); | ||
assertThat(cache.get("baz"), is(nullValue())); | ||
|
||
assertThat(meterRegistry.get("cache.gets").tag("result", "hit").functionCounter().count(), is(1.0)); | ||
await().atMost(Duration.ofSeconds(5)) | ||
.until(() -> meterRegistry.get("cache.puts").functionCounter().count(), is(1.0)); | ||
|
||
} | ||
|
||
} |