From 8916032dffaa781add197892dd760b93bda77ca6 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 18 Apr 2024 10:35:09 +0200 Subject: [PATCH 1/2] test: fix test failures in ActionEventInterceptorTest ``` Error: Failures: Error: ActionEventInterceptorTest.testInterceptComplete:247 Error: ActionEventInterceptorTest.testInterceptException:261 Error: ActionEventInterceptorTest.testInterceptStartAsync:234 expected: but was: ``` --- .../test/java/com/cloud/event/ActionEventInterceptorTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java index 9211ce167591..85275dc869b1 100644 --- a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java +++ b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java @@ -172,6 +172,7 @@ public EventVO answer(InvocationOnMock invocation) throws Throwable { account.setId(ACCOUNT_ID); user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN); + CallContext.register(user, account); Mockito.when(accountDao.findById(ACCOUNT_ID)).thenReturn(account); } @@ -265,7 +266,6 @@ public void testInterceptException() throws NoSuchMethodException { @Test public void testInterceptExceptionResource() throws NoSuchMethodException { - CallContext.register(user, account); Long resourceId = 1L; ApiCommandResourceType resourceType = ApiCommandResourceType.VirtualMachine; CallContext.current().setEventResourceId(resourceId); From 52c95a6d0239108a0bba7f7997d5e0a87074f944 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 19 Apr 2024 14:26:43 +0200 Subject: [PATCH 2/2] Update 8938: move CallContext.unregister as well --- .../test/java/com/cloud/event/ActionEventInterceptorTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java index 85275dc869b1..109cb585d8e5 100644 --- a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java +++ b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java @@ -198,6 +198,8 @@ public void teardown() { utils.init(); + CallContext.unregister(); + componentContextMocked.close(); } @@ -282,7 +284,6 @@ public void testInterceptExceptionResource() throws NoSuchMethodException { Assert.assertEquals(eventVO.getState(), com.cloud.event.Event.State.Completed); Assert.assertEquals(eventVO.getResourceId(), resourceId); Assert.assertEquals(eventVO.getResourceType(), resourceType.toString()); - CallContext.unregister(); } @Test