|
| 1 | +package io.sentry.systemtest |
| 2 | + |
| 3 | +import io.sentry.systemtest.util.TestHelper |
| 4 | +import kotlin.test.Test |
| 5 | +import kotlin.test.assertEquals |
| 6 | +import org.junit.Before |
| 7 | + |
| 8 | +class CacheSystemTest { |
| 9 | + lateinit var testHelper: TestHelper |
| 10 | + |
| 11 | + @Before |
| 12 | + fun setup() { |
| 13 | + testHelper = TestHelper("http://localhost:8080") |
| 14 | + testHelper.reset() |
| 15 | + } |
| 16 | + |
| 17 | + @Test |
| 18 | + fun `cache put and get produce spans`() { |
| 19 | + val restClient = testHelper.restClient |
| 20 | + |
| 21 | + // Save a todo (triggers @CachePut -> cache.put span) |
| 22 | + val todo = Todo(1L, "test-todo", false) |
| 23 | + restClient.saveCachedTodo(todo) |
| 24 | + assertEquals(200, restClient.lastKnownStatusCode) |
| 25 | + |
| 26 | + testHelper.ensureTransactionReceived { transaction, _ -> |
| 27 | + testHelper.doesTransactionContainSpanWithOp(transaction, "cache.put") |
| 28 | + } |
| 29 | + |
| 30 | + testHelper.reset() |
| 31 | + |
| 32 | + // Get the todo (triggers @Cacheable -> cache.get span, should be a hit) |
| 33 | + restClient.getCachedTodo(1L) |
| 34 | + assertEquals(200, restClient.lastKnownStatusCode) |
| 35 | + |
| 36 | + testHelper.ensureTransactionReceived { transaction, _ -> |
| 37 | + testHelper.doesTransactionContainSpanWithOp(transaction, "cache.get") |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + fun `cache evict produces span`() { |
| 43 | + val restClient = testHelper.restClient |
| 44 | + |
| 45 | + restClient.deleteCachedTodo(1L) |
| 46 | + |
| 47 | + testHelper.ensureTransactionReceived { transaction, _ -> |
| 48 | + testHelper.doesTransactionContainSpanWithOp(transaction, "cache.remove") |
| 49 | + } |
| 50 | + } |
| 51 | +} |
0 commit comments