-
Notifications
You must be signed in to change notification settings - Fork 41.5k
Add @DataElasticSearchTest support #8636
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the mongdb copy/paste this looks sensible.
} | ||
---- | ||
|
||
Embedded MongoDB generally works well for tests since it is fast and doesn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh? :)
* tests. Most tests should consider using {@link DataElasticsearchTest @DataElasticsearchTest} rather | ||
* than using this annotation directly. | ||
* | ||
* @author M. Deinum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency could you please use your full first name?
this.thrown.expect(NoSuchBeanDefinitionException.class); | ||
this.applicationContext.getBean(BookService.class); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
@snicoll did you mean to put this in the 1.5.x bucket? |
Wrong call, should be 2.0 I suppose. |
It's tempting to try an sneak it into 1.5.x, but 2.0 is better I think. |
OK I've polished the PR (see my branch). @mdeinum could you please configure your IDE to at least use tabs? So there is one thing I don't like is that the tests create an index and I really don't want that. Discussing with @wilkinsona we think it should probably default to something else with a property to specify it maybe. If someone wants to work on that, feel free to submit a PR on my fork. |
@philwebb I tried to implement this and it looks like a lot of work. On It's not very clear what we should do. Detect a |
@snicoll What's creating the data directory? Is it something in |
@philwebb our auto-configuration defaults to the current work directory. So, yes. We need to add a |
@snicoll What if we offered some kind of |
Perhaps the main auto-configuration should change then. Two things:
if that was a feature of the auto-configuration, the test auto-config would just flip a switch. |
In our specific situation, as we used gradle, we put the index in the build directory and recreate before every test. But as that isn't very portable that won't work here. We basically set the For testing this could, maybe, be put in the Could a specific |
How do you do that? |
We basically used the sledge hammer approach and tapped into the dirties context support much like the Would be nice if we could have something along the lines of |
I am not following. What do you mean by "context"? |
My bad. When using the dirties context approach a new Would it make sense to create an |
@mdeinum you're the one submitting this PR so if you know good defaults, by all means share them. |
@mdeinum are you going to refine your PR with what we've discussed here? |
01caa7a
to
25a5d56
Compare
This commit introduces the @DataElasticSearchTest annotation. See: spring-projectsgh-8544
25a5d56
to
7991126
Compare
In Elasticsearch 5 they have dropped official support for running embedded Elasticsearch. They do, however, provide EsIntegTestCase. Unfortunately, it's very picky about what's on the classpath and tests fail to launch if it finds any duplicate classes. For example it pulls in The alternative is to roll our own code to bootstrap an Elasticsearch node as part of |
That is too bad :( . I'm currently a bit swamped in work and finishing a book. If all goes well I probably have time next week to take another look at this. Could we take some inspiration from the |
It looks like this has been scuppered by the current situation with embedding Elasticsearch and the severe restrictions of |
Oh, this PR finally missed merging into Spring Boot? |
Yes. Please see the various comments above for the reasons why it could not be merged. |
This commit introduces the @DataElasticSearchTest annotation.
See: gh-8544