Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing a test with datastore fails #2248

Open
barreiro opened this issue Jan 21, 2025 · 7 comments
Open

Importing a test with datastore fails #2248

barreiro opened this issue Jan 21, 2025 · 7 comments
Labels
area/backend priority/medium Medium priority type/bug Something isn't working

Comments

@barreiro
Copy link
Collaborator

Describe the bug

The import of a test that uses a datastore other than postgres fails with the following exception on the logs

2025-01-21 12:46:32,735 ERROR [io.qua.ver.htt.run.QuarkusErrorHandler] (executor-thread-8870) HTTP Request to /api/test/import failed, error id: 41140e7d-3d3a-4647-8819-aac7449db9a0-26: jakarta.persistence.EntityExistsException: detached entity passed to persist: io.hyperfoil.tools.horreum.entity.backend.DatastoreConfigDAO
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:126)
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:167)
	at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:173)
	at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:767)
	at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:745)
	at io.quarkus.hibernate.orm.runtime.session.TransactionScopedSession.persist(TransactionScopedSession.java:146)
	at org.hibernate.engine.spi.SessionLazyDelegator.persist(SessionLazyDelegator.java:282)
	at org.hibernate.Session_OpdLahisOZ9nWRPXMsEFQmQU03A_Synthetic_ClientProxy.persist(Unknown Source)
	at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.persist(AbstractJpaOperations.java:105)
	at io.quarkus.hibernate.orm.panache.common.runtime.AbstractJpaOperations.persist(AbstractJpaOperations.java:100)
	at io.quarkus.hibernate.orm.panache.PanacheEntityBase.persist(PanacheEntityBase.java:65)
	at io.hyperfoil.tools.horreum.svc.TestServiceImpl.importTest(TestServiceImpl.java:738)
	at io.hyperfoil.tools.horreum.svc.TestServiceImpl_Subclass.importTest$$superforward(Unknown Source)
	at io.hyperfoil.tools.horreum.svc.TestServiceImpl_Subclass$$function$$14.apply(Unknown Source)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:73)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext$NextAroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:97)
	at io.hyperfoil.tools.horreum.server.RolesInterceptor.intercept(RolesInterceptor.java:75)
	at io.hyperfoil.tools.horreum.server.RolesInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:70)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext$NextAroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:97)
	at io.quarkus.security.runtime.interceptor.SecurityHandler.handle(SecurityHandler.java:27)
	at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor.intercept(RolesAllowedInterceptor.java:29)
	at io.quarkus.security.runtime.interceptor.RolesAllowedInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:70)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext$NextAroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:97)
	at io.quarkus.resteasy.reactive.server.runtime.StandardSecurityCheckInterceptor.intercept(StandardSecurityCheckInterceptor.java:44)
	at io.quarkus.resteasy.reactive.server.runtime.StandardSecurityCheckInterceptor_RolesAllowedInterceptor_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:70)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.proceed(AroundInvokeInvocationContext.java:62)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:136)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.invokeInOurTx(TransactionalInterceptorBase.java:107)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.doIntercept(TransactionalInterceptorRequired.java:38)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorBase.intercept(TransactionalInterceptorBase.java:61)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired.intercept(TransactionalInterceptorRequired.java:32)
	at io.quarkus.narayana.jta.runtime.interceptor.TransactionalInterceptorRequired_Bean.intercept(Unknown Source)
	at io.quarkus.arc.impl.InterceptorInvocation.invoke(InterceptorInvocation.java:42)
	at io.quarkus.arc.impl.AroundInvokeInvocationContext.perform(AroundInvokeInvocationContext.java:30)
	at io.quarkus.arc.impl.InvocationContexts.performAroundInvoke(InvocationContexts.java:27)
	at io.hyperfoil.tools.horreum.svc.TestServiceImpl_Subclass.importTest(Unknown Source)
	at io.hyperfoil.tools.horreum.svc.TestServiceImpl_ClientProxy.importTest(Unknown Source)
	at io.hyperfoil.tools.horreum.api.services.TestService$quarkusrestinvoker$importTest_6e0c8eaf2bc2e439fd1fde372d0fcb36e38bd77f.invoke(Unknown Source)
	at org.jboss.resteasy.reactive.server.handlers.InvocationHandler.handle(InvocationHandler.java:29)
	at io.quarkus.resteasy.reactive.server.runtime.QuarkusResteasyReactiveRequestContext.invokeHandler(QuarkusResteasyReactiveRequestContext.java:141)
	at org.jboss.resteasy.reactive.common.core.AbstractResteasyReactiveContext.run(AbstractResteasyReactiveContext.java:147)
	at io.quarkus.vertx.core.runtime.VertxCoreRecorder$14.runWith(VertxCoreRecorder.java:635)
	at org.jboss.threads.EnhancedQueueExecutor$Task.doRunWith(EnhancedQueueExecutor.java:2516)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2495)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1521)
	at org.jboss.threads.DelegatingRunnable.run(DelegatingRunnable.java:11)
	at org.jboss.threads.ThreadLocalResettingRunnable.run(ThreadLocalResettingRunnable.java:11)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: io.hyperfoil.tools.horreum.entity.backend.DatastoreConfigDAO
	at org.hibernate.event.internal.DefaultPersistEventListener.persist(DefaultPersistEventListener.java:90)
	at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:79)
	at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:55)
	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:127)
	at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:761)
	... 51 more

To Reproduce

Export a test that relies on a custom datastore and re-import it.

Version

0.16.3

@barreiro barreiro added the type/bug Something isn't working label Jan 21, 2025
Copy link

👋 @barreiro
Thanks for opening your first issue here! Be sure to follow the issue template!

@barreiro barreiro changed the title Importing a test witch datastore fails Importing a test with datastore fails Jan 21, 2025
@barreiro
Copy link
Collaborator Author

also, the export json for a test has

{
  [...]
  "datastoreId": 3,
  "datastore": {
    "type": "COLLECTORAPI"
    "id": 3,
    [...]
  },
}

which can result in conflicting information when importing,

@lampajr
Copy link
Member

lampajr commented Jan 22, 2025

For the records, for this specific use case, there existis a workaround to import a Test and associate it with an existing datastore:

  1. Remove the datastore entry
  2. Fill in the datastoreId with the id of the datastore to associate the test with

e.g.,

{
  [...]
  "datastoreId": 3,
  "datastore": null,
  [...]
}

@stalep
Copy link
Member

stalep commented Jan 22, 2025

Atm the current behavior of the imports is that if you import something with id's that's already existing, the import will overwrite what's in Horreum. I think we should also improve the documentations regarding imports to highlight this behavior.
Another discussion is to revisit this whole import "feature" as it can potentially alter tests it did not intend to change.

@stalep
Copy link
Member

stalep commented Jan 22, 2025

Same for SchemaService.importSchema...

@zakkak
Copy link
Contributor

zakkak commented Jan 22, 2025

Perhaps introducing a "duplicate" feature would help. Export/Import should be used as backup/restore, while Duplicate should be used to avoid the tedious process of redefining a lot of properties/settings when creating a new test.

@stalep
Copy link
Member

stalep commented Jan 22, 2025

Yes, or we can add a specific field to TestExport which will dictate what type of import it is (if it's a update or create)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/backend priority/medium Medium priority type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants