Hibernate-reactive: 研究如何为 JBang 创建模板以帮助处理错误报告

创建于 2021-04-23  ·  31评论  ·  资料来源: hibernate/hibernate-reactive

See https://github.com/jbangdev/jbang#init -templateshttps://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.如果用户可以使用JBang生成一个基本的测试项目,那就太好了,这样他们就可以快速开始创建一个项目来重现他们遇到的问题。

I haven't checked if this is feasible or helpful yet.我还没有检查这是否可行或有帮助。 In my head it should make it even easier than cloning a template from our repository .在我看来,它应该比从我们的存储库中克隆模板更容易。

en
testing

所有31条评论

@maxandersen already played with this. @maxandersen已经玩过这个。 What he didn't like, and what might also be a problem here, is that he couldn't easily use a testcontainers database.他不喜欢的,也可能是这里的一个问题,是他不能轻易地使用 testcontainers 数据库。

en

It works but yeah users would need to manually setup the database.它可以工作,但是是的,用户需要手动设置数据库。

But so should users using more complex setups :)但是用户也应该使用更复杂的设置:)

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.您可以做的是通过测试容器手动设置 jbang 脚本,而不是使用 jdbc url 魔术,它(还)不适用于 hibernate 反应式。

en

我确实简要介绍了如何使我们的测试套件中的 testcontainers 引导代码可重用,但这并不是那么简单。

en

我的意思是... testcontainers 是一个很棒的工具...但是我在这里冒昧地说,我们可以期望使用 Hibernate Reactive(或 ORM)的人能够在没有它的情况下启动数据库 :-)

en

It's certainly not a deal breaker to me, most of the boring part is really the configuration of the project.这对我来说当然不是什么大问题,大部分无聊的部分实际上是项目的配置。 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.如果我必须在能够运行应用程序的主程序之前手动启动一个启动脚本的数据库,那已经是一个很大的改进。

en

Sure, that's fine.当然,那很好。 But it's a nice-to-have.但这是一个不错的选择。

en

考虑一下,我们可能甚至不需要模板,我们可以提供一个 java 文件,其中包含 JBang 运行它所需的所有依赖项。

en

我通过“模板”计算出您希望通过数据库类型进行参数化。

en

I was talking about a JBang template, something that would allow the user to write:我在谈论一个 JBang 模板,它允许用户编写:

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

but I guess this would also be possible:但我想这也是可能的:

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:现在我认为我们可以通过提供单个文件(或每个数据库一个文件)来实现相同的结果,以便用户可以使用以下命令运行它:

jbang HReactiveWithDb2.java

With the caveat that a Db2 instance with the right credentials must be already running.需要注意的是,具有正确凭证的 Db2 实例必须已经在运行。

Then they could start editing it with:然后他们可以开始编辑它:

 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.我们可以想办法添加我们想要的所有花里胡哨,但这对我来说是一个很好的起点。

en

In my previous example, HReactiveWithDb2.java is somewhere on our GitHub repository and a user has to download it first.在我之前的示例中, HReactiveWithDb2.java位于我们的 GitHub 存储库中,用户必须先下载它。

Although, I expect JBang to have some way to run something like:虽然,我希望 JBang 有一些方法来运行类似的东西:

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

好吧,jbang 模板对参数 AFAIU 有某种支持,我认为这足以说明在某个persistence.xml文件中进行切换。

en

当然,听起来很棒。

en

Very interesting!很有意思!

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.您可能要考虑的另一件事是:Quarkus 用户经常被鼓励创建一个“reproducer 项目”,但在大多数情况下,这最终成为我必须重新适应真正的集成测试以合并到 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.我确实想知道我们是否可以构建我们的“复制器”,使其可以自动提升到新的集成测试中。

en

您可以让“主”类基本上是一个 junit 测试运行器,它运行带有@Test的类。

en

Btw.顺便提一句。 If Properties / qute template is not enough / not working let me know.如果属性/qute 模板不够/不起作用,请告诉我。 The init templates are new so if you find things missing I Can easily fix/release new jbang.初始化模板是新的,所以如果您发现缺少的东西,我可以轻松修复/发布新的 jbang。

en

@maxanderson我可以添加模板并使用它们进行初始化,谢谢!

en

I'm looking at our hibernate-reactive examples which use the entity manager factory and persistence.xml and separate entity classes.我正在查看我们使用实体管理器工厂和persistence.xml以及单独的实体类的休眠反应式示例 The tests chain multiple transactions by waiting indefinitely .测试通过等待indefinitely来链接多个交易。 All of our HR JUnit tests use chained CompletionStage 's as opposed to the single session transactions used in our examples .我们所有的 HR JUnit 测试都使用链式CompletionStage ,而不是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. JBang 功能允许在add (或注册)进程上附加资源(实体类和persistence.xml ),这些资源将包含在 Jbang 模板注册表中。 This will result in a copy of those entities will be included in the project and build.这将导致那些实体的副本将包含在项目中并构建。 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.所以理论上,我们可以生成Main.java和/或MutinyMain.java测试类并最终得到类似于这些示例目录的内容。

Note there is another feature that uses .jsh script that allows setting user-defined parameters to be replaced in a template file.请注意,还有另一个使用.jsh脚本的功能,它允许在模板文件中设置要替换的用户定义参数。 (alluded to earlier ^^^) but @MaxAndersen indicated they could be added to the JBang init command. (之前提到过^^^)但@MaxAndersen表示可以将它们添加到JBang init命令中。

Questions:问题:

  1. Is there a target hibernate-reactive user/customer and use case we're aiming for?我们的目标是否存在目标休眠反应式用户/客户和用例?

    • Based on the complexity, we may need to build/publish a hibernate-reactive-test to maven, which would need to be maintained基于复杂性,我们可能需要构建/发布一个hibernate-reactive-test到 maven,这需要维护
  2. Do we want to be able to test these generated tests against older or newer versions of HR & HR ORM?我们是否希望能够针对较旧或较新版本的 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 )基本模板需要在项目构建期间引入的依赖项(如未来的导入)(例如: //DEPS org.hibernate:hibernate-core:5.4.10.Final
    • This would help users define/document their build environment as part of the test generation这将帮助用户定义/记录他们的构建环境作为测试生成的一部分
  3. Simple examples like we have now are still viable, of course.当然,像我们现在这样的简单例子仍然是可行的。

en

我建议只做目前可能工作的最简单的事情。

en

@blafond , here's your use case: @blafond ,这是您的用例:
You are User and found this issue while using hibernate reactive in your您是用户,在您的系统中使用休眠反应式时发现了这个问题
project : https://github.com/hibernate/hibernate-reactive/issues/702项目: https ://github.com/hibernate/hibernate-reactive/issues/702

You want to send us a reproducer without having to clone the whole您想向我们发送复制器,而无需克隆整个
hibernate reactive project and without having to spend too much time on all休眠反应式项目,而不必花太多时间在所有
the scaffolding needed to create a brand new project.创建一个全新项目所需的脚手架。 Ideally, with jbang,理想情况下,使用 jbang,
you could just send us a single file and we could run it.您只需向我们发送一个文件,我们就可以运行它。

Use ORM 5.4, the default, for now.现在使用默认的 ORM 5.4。
Not sure why we need to worry about maven, but do what you think is right.不知道为什么我们需要担心 maven,但做你认为正确的事情。

Don't worry about CI, if it's easy for a user to run, it's easy for us to不用担心 CI,如果它对用户来说很容易运行,那么对我们来说很容易
add it to ci将其添加到 ci

On Wed, 5 May 2021, 21:48 Gavin King, @ . 2021 年 5 月 5 日,星期三,21:48 Gavin King, @ . * > wrote: * > 写道:

I would suggest just doing the Simplest Thing That Could Possibly Work for我建议只做可能有用的最简单的事情
now.现在。


You are receiving this because you authored the thread.您收到此消息是因为您编写了该主题。
Reply to this email directly, view it on GitHub直接回复此邮件,在 GitHub 上查看
https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030 , https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030
or unsubscribe或退订
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澄清一下,这个问题是使用 quarkus 发现的,但是复制器
should only use hibernate reactive应该只使用休眠反应

On Thu, 6 May 2021, 10:51 Davide D'Alto, @ . 2021 年 5 月 6 日星期四 10:51,Davide D'Alto, @ . * > wrote: * > 写道:

@blafond , here's your use case: @blafond ,这是您的用例:
You are User and found this issue while using hibernate reactive in your您是用户,在您的系统中使用休眠反应式时发现了这个问题
project : https://github.com/hibernate/hibernate-reactive/issues/702项目: https ://github.com/hibernate/hibernate-reactive/issues/702

You want to send us a reproducer without having to clone the whole您想向我们发送复制器,而无需克隆整个
hibernate reactive project and without having to spend too much time on all休眠反应式项目,而不必花太多时间在所有
the scaffolding needed to create a brand new project.创建一个全新项目所需的脚手架。 Ideally, with jbang,理想情况下,使用 jbang,
you could just send us a single file and we could run it.您只需向我们发送一个文件,我们就可以运行它。

Use ORM 5.4, the default, for now.现在使用默认的 ORM 5.4。
Not sure why we need to worry about maven, but do what you think is right.不知道为什么我们需要担心 maven,但做你认为正确的事情。

Don't worry about CI, if it's easy for a user to run, it's easy for us to不用担心 CI,如果它对用户来说很容易运行,那么对我们来说很容易
add it to ci将其添加到 ci

On Wed, 5 May 2021, 21:48 Gavin King, @ . 2021 年 5 月 5 日,星期三,21:48 Gavin King, @ . * > wrote: * > 写道:

I would suggest just doing the Simplest Thing That Could Possibly Work我建议只做可能可行的最简单的事情
for now.目前。


You are receiving this because you authored the thread.您收到此消息是因为您编写了该主题。
Reply to this email directly, view it on GitHub直接回复此邮件,在 GitHub 上查看
https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030 , https://github.com/hibernate/hibernate-reactive/issues/721#issuecomment-832997030
or unsubscribe或退订
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 ,总是会有与 HR 集成的错误。 For example, suppose Quarkus passes arguments to HR in the wrong order.例如,假设 Quarkus 以错误的顺序将参数传递给 HR。 This is not a use case that you need to be concerned about here.这不是您需要在这里关注的用例。 Integration bugs will need to be reproduced in some other way.集成错误将需要以其他方式重现。

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.让我们轻松地将用户的复制器添加到单元测试的一种方法是让模板以某种方式扩展BaseReactiveTest ,因此我们所要做的就是复制/粘贴到测试套件中。 I have no idea if that is the proper approach here.我不知道这是否是正确的方法。 I'm just mentioning it as an example.我只是举个例子。

en

@maxandersen @gavinking What was the problem with JBang and testcontainers? @maxandersen @gavinking JBang 和 testcontainers 有什么问题? It seems to work fine to me:对我来说似乎工作正常:

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.是的,如果您手动设置它,它可以工作。 Issue is it won't work by just setting the jdbc or similar url.问题是仅通过设置 jdbc 或类似的 url 是行不通的。

en

问题在于使用包含tc:的 JDBC URL。

en

Ah, I remember now.啊,我现在想起来了。 We still have this issue open: https://github.com/hibernate/hibernate-reactive/issues/468我们仍然有这个问题: https ://github.com/hibernate/hibernate-reactive/issues/468

en

I think we have good starting point now and we can improve on it later.我认为我们现在有一个很好的起点,我们可以在以后改进它。
In particular, when we have a solution for #468特别是当我们有 #468 的解决方案时

en

is there a reason you don't have that jbang script available as a template so you can do是否有一个原因您没有该 jbang 脚本可用作模板,所以您可以这样做

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.不,不是真的,主要是因为我仍在调整它,而且我发现它不是模板时更容易工作。

But I'm not sure I understand the syntax you are using.但我不确定我是否理解您使用的语法。 What's testcase@hibernate/hibernate-reactive ? 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?是通过jbang template add ...添加到目录中的东西还是引用了其他东西?

Would it be possible to refer to a github repository as the location of the template?是否可以将 github 存储库引用为模板的位置?

en

testcase is the template name found in jbang-catalog. testcase 是在 jbang-catalog 中找到的模板名称。

hibernate/hibernate-reactive maps to github.com/hibernate/hibernate-reactive. hibernate/hibernate-reactive 映射到 github.com/hibernate/hibernate-reactive。

so that is the github repository location.这就是 github 存储库位置。

en

Ah nice!很好! I will try it我会试试

en
此页面是否有帮助?
0 / 5 - 0 等级

相关问题

hantsy picture hantsy  ·  7评论

tsegismont picture tsegismont  ·  20评论

markusdlugi picture markusdlugi  ·  30评论

gavinking picture gavinking  ·  16评论

murphye picture murphye  ·  40评论