Hibernate-reactive: Investigue cómo crear una plantilla para JBang para ayudar con los informes de errores

Creado en 23 abr. 2021  ·  31Comentarios  ·  Fuente: hibernate/hibernate-reactive

See https://github.com/jbangdev/jbang#init -templates Ver https://github.com/jbangdev/jbang#init -templates

It would be nice if users could generate a basic test project using JBang so that they have a quick way to start creating a project for reproducing the issue they are having. Sería bueno si los usuarios pudieran generar un proyecto de prueba básico usando JBang para que tengan una forma rápida de comenzar a crear un proyecto para reproducir el problema que están teniendo.

I haven't checked if this is feasible or helpful yet. Todavía no he comprobado si esto es factible o útil. In my head it should make it even easier than cloning a template from our repository . En mi cabeza, debería ser aún más fácil que clonar una plantilla de nuestro repositorio .

en
testing

Todos 31 comentarios

@maxandersen already played with this. @maxandersen ya jugó con esto. What he didn't like, and what might also be a problem here, is that he couldn't easily use a testcontainers database. Lo que no le gustó, y lo que también podría ser un problema aquí, es que no podía usar fácilmente una base de datos de contenedores de prueba.

en

It works but yeah users would need to manually setup the database. Funciona, pero sí, los usuarios tendrían que configurar manualmente la base de datos.

But so should users using more complex setups :) Pero también deberían hacerlo los usuarios que usan configuraciones más complejas :)

What you can do is to have the jbang script setup via test containers manually rather than using the jdbc url magic which does not work (yet) with hibernate reactive. Lo que puede hacer es tener la configuración del script jbang a través de contenedores de prueba manualmente en lugar de usar la magia de URL jdbc que no funciona (todavía) con hibernate reactivo.

en

Miré brevemente cómo hacer que el código de arranque de testcontainers en nuestro conjunto de pruebas sea reutilizable, pero no iba a ser tan trivial.

en

Quiero decir... testcontainers es una gran herramienta... pero me voy a arriesgar aquí y digo que podemos esperar que las personas que usan Hibernate Reactive (u ORM) puedan iniciar una base de datos sin él :-)

en

It's certainly not a deal breaker to me, most of the boring part is really the configuration of the project. Ciertamente no es un factor decisivo para mí, la mayor parte de la parte aburrida es realmente la configuración del proyecto. If I have to start a db launching a script manually before being able to run the main of the app, it would already be a great improvement. Si tengo que iniciar una base de datos iniciando un script manualmente antes de poder ejecutar la aplicación principal, ya sería una gran mejora.

en

Sure, that's fine. Claro, está bien. But it's a nice-to-have. Pero es bueno tenerlo.

en

Pensándolo bien, probablemente ni siquiera necesitemos una plantilla para empezar, podríamos proporcionar un archivo java con todas las dependencias necesarias para que JBang lo ejecute.

en

Supuse que por "plantilla" esperaba parametrizar por tipo de base de datos.

en

I was talking about a JBang template, something that would allow the user to write: Estaba hablando de una plantilla JBang, algo que le permitiría al usuario escribir:

jbang init --template=hibernate-reactive Issue456.java

but I guess this would also be possible: pero supongo que esto también sería posible:

jbang init --template=hibernate-reactive-db2 Issue456.java

Now I think we could achieve the same result providing a single file (or one per database) so that a user can run it with: Ahora creo que podríamos lograr el mismo resultado proporcionando un solo archivo (o uno por base de datos) para que un usuario pueda ejecutarlo con:

jbang HReactiveWithDb2.java

With the caveat that a Db2 instance with the right credentials must be already running. Con la salvedad de que ya debe estar ejecutándose una instancia de Db2 con las credenciales correctas.

Then they could start editing it with: Entonces podrían empezar a editarlo con:

 jbang edit --open=idea  HReactiveWithDb2.java

We can think of ways to add all the bells and whistles we want, but this would be a good starting point for me. Podemos pensar en formas de agregar todas las campanas y silbatos que queramos, pero este sería un buen punto de partida para mí.

en

In my previous example, HReactiveWithDb2.java is somewhere on our GitHub repository and a user has to download it first. En mi ejemplo anterior, HReactiveWithDb2.java está en algún lugar de nuestro repositorio de GitHub y el usuario debe descargarlo primero.

Although, I expect JBang to have some way to run something like: Aunque espero que JBang tenga alguna forma de ejecutar algo como:

jbang https://github.com/hibernate/hibernate-reactive/HReactiveWithDb2.java
en

Bueno, las plantillas jbang tienen algún tipo de soporte para los parámetros AFAIU, y creo que eso debería ser suficiente para cambiar un determinado archivo persistence.xml .

en

Claro, suena genial.

en

Very interesting! ¡Muy interesante!

One additional thing that maybe you want to consider: very often Quarkus users are encouraged to create a "reproducer project" but in most cases this then ends up being something I have to re-adapt into a real integration test to be merged in Quarkus mainline. Una cosa adicional que tal vez desee considerar: muy a menudo se alienta a los usuarios de Quarkus a crear un "proyecto de reproducción", pero en la mayoría de los casos esto termina siendo algo que tengo que readaptar en una prueba de integración real para fusionarlo en la línea principal de Quarkus. .

I do wonder if we could structure our "reproducers" in such a way that it could be automatically promoted into a new integration test. Me pregunto si podríamos estructurar nuestros "reproductores" de tal manera que pudieran promoverse automáticamente a una nueva prueba de integración.

en

Puede hacer que la clase "principal" sea básicamente un corredor de pruebas junit que ejecuta clases con @Test en él.

en

Btw. Por cierto. If Properties / qute template is not enough / not working let me know. Si la plantilla Propiedades/Qute no es suficiente/no funciona, hágamelo saber. The init templates are new so if you find things missing I Can easily fix/release new jbang. Las plantillas de inicio son nuevas, por lo que si encuentra que faltan cosas, puedo arreglarlas/lanzarlas fácilmente.

en

@maxanderson ¡Puedo agregar plantillas e iniciar con ellas, gracias!

en

I'm looking at our hibernate-reactive examples which use the entity manager factory and persistence.xml and separate entity classes. Estoy mirando nuestros ejemplos reactivos de hibernación que usan la fábrica de administradores de entidades y persistence.xml y clases de entidades separadas. The tests chain multiple transactions by waiting indefinitely . Las pruebas encadenan múltiples transacciones esperando indefinitely . All of our HR JUnit tests use chained CompletionStage 's as opposed to the single session transactions used in our examples . Todas nuestras pruebas de HR JUnit usan CompletionStage encadenados en lugar de las transacciones de sesión única que se usan en nuestro examples .

JBang features allow attaching resources (entity classes and persistence.xml ) on the add (or registration) process which will be included in the Jbang template registry. Las funciones de JBang permiten adjuntar recursos (clases de entidad y persistence.xml ) en el proceso de add (o registro) que se incluirán en el registro de plantilla de Jbang. This will result in a copy of those entities will be included in the project and build. Esto dará como resultado que se incluya una copia de esas entidades en el proyecto y la construcción. So in theory, we can generate the Main.java and/or MutinyMain.java test classes and end up with something similar to these example directories. Entonces, en teoría, podemos generar las clases de prueba Main.java y/o MutinyMain.java y terminar con algo similar a estos directorios de ejemplo.

Note there is another feature that uses .jsh script that allows setting user-defined parameters to be replaced in a template file. Tenga en cuenta que hay otra función que utiliza el script .jsh que permite configurar los parámetros definidos por el usuario para que se reemplacen en un archivo de plantilla. (alluded to earlier ^^^) but @MaxAndersen indicated they could be added to the JBang init command. (aludido anteriormente ^^^) pero @MaxAndersen indicó que podrían agregarse al comando JBang init .

Questions: Preguntas:

  1. Is there a target hibernate-reactive user/customer and use case we're aiming for? ¿Hay un usuario/cliente objetivo reactivo a la hibernación y un caso de uso al que apuntamos?

    • Based on the complexity, we may need to build/publish a hibernate-reactive-test to maven, which would need to be maintained En función de la complejidad, es posible que necesitemos crear/publicar un hibernate-reactive-test en maven, que debería mantenerse
  2. Do we want to be able to test these generated tests against older or newer versions of HR & HR ORM? ¿Queremos poder probar estas pruebas generadas contra versiones anteriores o más nuevas de HR & HR ORM?

    • The basic templates require dependencies (like future imports) that are pulled in during project build (example: //DEPS org.hibernate:hibernate-core:5.4.10.Final ) Las plantillas básicas requieren dependencias (como futuras importaciones) que se extraen durante la construcción del proyecto (ejemplo: //DEPS org.hibernate:hibernate-core:5.4.10.Final )
    • This would help users define/document their build environment as part of the test generation Esto ayudaría a los usuarios a definir/documentar su entorno de construcción como parte de la generación de pruebas.
  3. Simple examples like we have now are still viable, of course. Los ejemplos simples como los que tenemos ahora todavía son viables, por supuesto.

en

Sugeriría simplemente hacer lo más simple que posiblemente podría funcionar por ahora.

en

@blafond , here's your use case: @blafond , aquí está su caso de uso:
You are User and found this issue while using hibernate reactive in your Usted es usuario y encontró este problema mientras usaba hibernate reactivo en su
project : https://github.com/hibernate/hibernate-reactive/issues/702 proyecto: https://github.com/hibernate/hibernate-reactive/issues/702

You want to send us a reproducer without having to clone the whole Quiere enviarnos un reproductor sin tener que clonar todo
hibernate reactive project and without having to spend too much time on all proyecto reactivo de hibernación y sin tener que dedicar demasiado tiempo a todos
the scaffolding needed to create a brand new project. el andamiaje necesario para crear un nuevo proyecto. Ideally, with jbang, Idealmente, con jbang,
you could just send us a single file and we could run it. podría enviarnos un solo archivo y podríamos ejecutarlo.

Use ORM 5.4, the default, for now. Use ORM 5.4, el predeterminado, por ahora.
Not sure why we need to worry about maven, but do what you think is right. No estoy seguro de por qué tenemos que preocuparnos por Maven, pero haz lo que creas correcto.

Don't worry about CI, if it's easy for a user to run, it's easy for us to No se preocupe por CI, si es fácil de ejecutar para un usuario, es fácil para nosotros
add it to ci agregarlo a ci

On Wed, 5 May 2021, 21:48 Gavin King, @ . El miércoles 5 de mayo de 2021 a las 21:48 Gavin King, @ . * > wrote: * > escribió:

I would suggest just doing the Simplest Thing That Could Possibly Work for Sugeriría simplemente hacer lo más simple que posiblemente podría funcionar para
now. ahora.


You are receiving this because you authored the thread. Usted está recibiendo esto porque usted fue el autor del hilo.
Reply to this email directly, view it on GitHub Responda a este correo electrónico directamente, véalo en GitHub
https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030 , https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030 ,
or unsubscribe o darse de baja
https://github.com/notifications/unsubscribe-auth/AAEIQ5JQIPGKCNFSHOWKCD3TMGVKTANCNFSM43OEZPUQ https://github.com/notifications/unsubscribe-auth/AAEIQ5JQIPGKCNFSHOWKCD3TMGVKTANCNFSM43OEZPUQ
. .

en

Just to clarify, the issue was found using quarkus, but the reproducer Solo para aclarar, el problema se encontró usando quarkus, pero el reproductor
should only use hibernate reactive solo debe usar hibernación reactiva

On Thu, 6 May 2021, 10:51 Davide D'Alto, @ . El jueves, 6 de mayo de 2021, 10:51 Davide D'Alto, @ . * > wrote: * > escribió:

@blafond , here's your use case: @blafond , aquí está su caso de uso:
You are User and found this issue while using hibernate reactive in your Usted es usuario y encontró este problema mientras usaba hibernate reactivo en su
project : https://github.com/hibernate/hibernate-reactive/issues/702 proyecto: https://github.com/hibernate/hibernate-reactive/issues/702

You want to send us a reproducer without having to clone the whole Quiere enviarnos un reproductor sin tener que clonar todo
hibernate reactive project and without having to spend too much time on all proyecto reactivo de hibernación y sin tener que dedicar demasiado tiempo a todos
the scaffolding needed to create a brand new project. el andamiaje necesario para crear un nuevo proyecto. Ideally, with jbang, Idealmente, con jbang,
you could just send us a single file and we could run it. podría enviarnos un solo archivo y podríamos ejecutarlo.

Use ORM 5.4, the default, for now. Use ORM 5.4, el predeterminado, por ahora.
Not sure why we need to worry about maven, but do what you think is right. No estoy seguro de por qué tenemos que preocuparnos por Maven, pero haz lo que creas correcto.

Don't worry about CI, if it's easy for a user to run, it's easy for us to No se preocupe por CI, si es fácil de ejecutar para un usuario, es fácil para nosotros
add it to ci agregarlo a ci

On Wed, 5 May 2021, 21:48 Gavin King, @ . El miércoles 5 de mayo de 2021 a las 21:48 Gavin King, @ . * > wrote: * > escribió:

I would suggest just doing the Simplest Thing That Could Possibly Work Sugeriría simplemente hacer lo más simple que posiblemente podría funcionar
for now. por ahora.


You are receiving this because you authored the thread. Usted está recibiendo esto porque usted fue el autor del hilo.
Reply to this email directly, view it on GitHub Responda a este correo electrónico directamente, véalo en GitHub
https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030 , https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030 ,
or unsubscribe o darse de baja
https://github.com/notifications/unsubscribe-auth/AAEIQ5JQIPGKCNFSHOWKCD3TMGVKTANCNFSM43OEZPUQ https://github.com/notifications/unsubscribe-auth/AAEIQ5JQIPGKCNFSHOWKCD3TMGVKTANCNFSM43OEZPUQ
. .

en

@blafond , invariably, there will be bugs integrating with HR. @blafond , invariablemente, habrá errores de integración con recursos humanos. For example, suppose Quarkus passes arguments to HR in the wrong order. Por ejemplo, suponga que Quarkus pasa los argumentos a Recursos Humanos en el orden incorrecto. This is not a use case that you need to be concerned about here. Este no es un caso de uso por el que deba preocuparse aquí. Integration bugs will need to be reproduced in some other way. Los errores de integración deberán reproducirse de alguna otra manera.

One way to make it easy for us to add a user's reproducer to a unit test is to have the template somehow extend BaseReactiveTest , so all we have to do is copy/paste into the test suite. Una forma de facilitarnos la adición del reproductor de un usuario a una prueba unitaria es hacer que la plantilla se extienda de alguna manera BaseReactiveTest , por lo que todo lo que tenemos que hacer es copiar y pegar en el conjunto de pruebas. I have no idea if that is the proper approach here. No tengo idea si ese es el enfoque adecuado aquí. I'm just mentioning it as an example. Solo lo menciono como ejemplo.

en

@maxandersen @gavinking What was the problem with JBang and testcontainers? @maxandersen @gavinking ¿Cuál fue el problema con JBang y los contenedores de prueba? It seems to work fine to me: Parece que funciona bien para mí:

jbang https://github.com/DavideD/hibernate-reactive/blob/721-jbang-executable-test/tooling/jbang/SampleIssueTest.java
en

Yes if you set it up manually it works. Sí, si lo configura manualmente, funciona. Issue is it won't work by just setting the jdbc or similar url. El problema es que no funcionará simplemente configurando jdbc o una URL similar.

en

El problema es con el uso de URL de JDBC que contienen tc: .

en

Ah, I remember now. Ah, ahora lo recuerdo. We still have this issue open: https://github.com/hibernate/hibernate-reactive/issues/468 Todavía tenemos este problema abierto: https://github.com/hibernate/hibernate-reactive/issues/468

en

I think we have good starting point now and we can improve on it later. Creo que tenemos un buen punto de partida ahora y podemos mejorarlo más adelante.
In particular, when we have a solution for #468 En particular, cuando tenemos una solución para #468

en

is there a reason you don't have that jbang script available as a template so you can do ¿Hay algún motivo por el que no tenga ese script jbang disponible como plantilla para poder hacer

jbang init -t testcase@hibernate/hibernate-reactive mytest.java ? jbang init -t testcase@hibernate/hibernate-reactive mytest.java ?

en

No, not really, mainly because I'm still tweaking it and I find it easier to work when it's not a template. No, en realidad no, principalmente porque todavía lo estoy ajustando y me resulta más fácil trabajar cuando no es una plantilla.

But I'm not sure I understand the syntax you are using. Pero no estoy seguro de entender la sintaxis que está utilizando. What's testcase@hibernate/hibernate-reactive ? ¿Cuánto es testcase@hibernate/hibernate-reactive ? Is it something that's been added to the catalog via jbang template add ... or does it refer to something else? ¿Es algo que se agregó al catálogo a través jbang template add ... o se refiere a otra cosa?

Would it be possible to refer to a github repository as the location of the template? ¿Sería posible hacer referencia a un repositorio de github como la ubicación de la plantilla?

en

testcase is the template name found in jbang-catalog. testcase es el nombre de la plantilla que se encuentra en jbang-catalog.

hibernate/hibernate-reactive maps to github.com/hibernate/hibernate-reactive. hibernate/hibernate-reactive mapea a github.com/hibernate/hibernate-reactive.

so that is the github repository location. así que esa es la ubicación del repositorio de github.

en

Ah nice! ¡Oh bien! I will try it voy a intentarlo

en
¿Fue útil esta página
0 / 5 - 0 calificaciones