Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Feb 01 07:26

    dependabot[bot] on gradle

    (compare)

  • Feb 01 07:26

    xvik on master

    Bump com.github.ben-manes.versi… Merge pull request #275 from xv… (compare)

  • Feb 01 07:26
    xvik closed #275
  • Jan 31 23:01
    dependabot[bot] labeled #275
  • Jan 31 23:01
    dependabot[bot] opened #275
  • Jan 31 23:01

    dependabot[bot] on gradle

    Bump com.github.ben-manes.versi… (compare)

  • Jan 31 05:38

    dependabot[bot] on gradle

    (compare)

  • Jan 31 05:38

    xvik on master

    Bump com.gradle.enterprise from… Merge pull request #274 from xv… (compare)

  • Jan 31 05:38
    xvik closed #274
  • Jan 30 23:02
    dependabot[bot] labeled #274
  • Jan 30 23:02

    dependabot[bot] on gradle

    Bump com.gradle.enterprise from… (compare)

  • Jan 30 23:02
    dependabot[bot] opened #274
  • Jan 27 05:03

    dependabot[bot] on gradle

    (compare)

  • Jan 27 05:02

    xvik on master

    Bump system-stubs-jupiter from … Merge pull request #273 from xv… (compare)

  • Jan 27 05:02
    xvik closed #273
  • Jan 26 23:01
    dependabot[bot] labeled #273
  • Jan 26 23:01

    dependabot[bot] on gradle

    Bump system-stubs-jupiter from … (compare)

  • Jan 26 23:01
    dependabot[bot] opened #273
  • Jan 05 11:59

    xvik on freedom

    no hk2 check add contracts debug (compare)

  • Jan 05 09:41

    dependabot[bot] on gradle

    (compare)

Eddie Xie
@oeddyo
would love to see TestDropwizardAppExtension come to live. I'm trying to load my embededPostgres (instead of using dw's h2) and want to dynamically set the port so I can run parallel testing. Currently hitting some obstacles
and TestDropwizardAppExtension looks promising
Fazeem Mohammed
@fazeem84
Yes...I would like to have something like zonkyio https://github.com/zonkyio/embedded-database-spring-test/blob/master/README.md
Vyacheslav Rusakov
@xvik

@oeddyo configuration overrides is a dropwizard feature so you can use random ports even now (from dropwozard docs:

ConfigOverride.config("server.applicationConnectors[0].port", "0") // Optional, if not using a separate testing-specific configuration file, use a randomly selected port

New extension just a bit simplify declaration (nothing you can't achieve now).

Vyacheslav Rusakov
@xvik
@fazeem84 I will not do anything like this in the near future: it's obviously out of guicey scope. More importantly, something like this requires common datasource management approach like in spring-boot, but it is not the case in dropwizard (or guicey). It would be possible to do something generic, easilly adoptable to exact project, but it would be quite a lot of work.. I doubt I will ever look st this sight, but I hope someone else would do good junit 5 extension and it would be simply used together with new extensions (junit 5 extensions model is very good)
Eddie Xie
@oeddyo
I got stucked with using a random port for DropwizardAppExtension. I have class level parallel set so I wanted to have a server per class. However, when I run one test it goes fine, but when I run multiple, only one DropwizardApp was created.
I thought it should be easy to do parallel test with dropwizard but looks like I was essentially doing TestDropwizardAppExtension?
I'd love to use TestDropwizardAppExtension in my code but since it's not released yet, had to copy & paste into my code and messed up with deps :(
so I guess waiting for your release is my best bet? @xvik
Eddie Xie
@oeddyo
currently I have two test files. I have a DropwizardAppExtension for each and I override the port to use random ports. When I run each file it runs smoothly, but when I run two in parallel, one will somehow "know" about the other and fail. I tried to debug and find only one server can be created no matter how but DropwizardTest is like a rabbit hole to me. Spent abt two days with no progress :(
Vyacheslav Rusakov
@xvik

so both your test files have:

@ExtendWith(DropwizardExtensionsSupport)

static DropwizardAppExtension ext = new DropwizardAppExtension(App.class)

?

Eddie Xie
@oeddyo
yeah
public class AccountResourceIT {
oops somehow it eats my code
image.png
Vyacheslav Rusakov
@xvik
hmm looks good
how other test fails? any exception?
Eddie Xie
@oeddyo
yes it says the port was bind
image.png
so the two classes are almost identical
if AppResourceIT runs first and bind 30000, for some reason in AccountResourceIT it will say 30000 is used (even though it should use port 20000)
Vyacheslav Rusakov
@xvik
i'll try to reproduce
Eddie Xie
@oeddyo
cool. i can make a minimized version
did you try to run multiple tests in parallel with TestDropwizardAppExtension?
Vyacheslav Rusakov
@xvik
no)
Vyacheslav Rusakov
@xvik
aaaah got it!
it wiill not work, configOverrides work through the system properties: so each test bind override with ConfigOverride#addToSystemProperties:
public void addToSystemProperties() {
        System.setProperty(propertyPrefix + key, value.get());
    }
Vyacheslav Rusakov
@xvik
Use 0 instead of exact port number: dropwizard will apply random ports itself and everythong will work
Eddie Xie
@oeddyo
wooohooo
let me try it
Eddie Xie
@oeddyo
when you say "use 0 instead off exact port number", do you mean on client use 0 or set ConfigOverride.config(server.applicationConnectors[0].port, 0)?
Vyacheslav Rusakov
@xvik
on server
on client you can retrieve application port using rule instance: DROPWIZARD.getLocalPort()
Eddie Xie
@oeddyo
got it! Trying it out now
Eddie Xie
@oeddyo
works like a charm!
Vyacheslav Rusakov
@xvik
great!
Eddie Xie
@oeddyo
thanks for a ton! I'll never discover if you set port as 0 DW will just use a random number lol
Vyacheslav Rusakov
@xvik
:)
Eddie Xie
@oeddyo
Hi @xvik I'm having some trouble setting dynamic db-jdbc. I think the problem is identical with the one we had yesterday (i.e. ConfigOverride.config will write to system property)
currently i'm doing dropwizardApp = new DropwizardAppExtension<>( HttpServer.class, "src/test/resources/dropwizard-test-config.yml", ConfigOverride.config( "database.url", singleInstancePostgresExtension.getEmbeddedPostgres().getJdbcUrl( "postgres", "postgres") ), ConfigOverride.config( "server.applicationConnectors[0].port", String.valueOf(0) ), ConfigOverride.config( "server.adminConnectors[0].port", String.valueOf(0) ), ConfigOverride.config( "engine.indexDataPrefix", tempDir.toAbsolutePath().toString() ) );
image.png
database.url is set dynamically. but then when running multiple test cases they get overriden by each other. Is there any way I can set the db url dynamically just like how we set the port?
Vyacheslav Rusakov
@xvik
hi! No, as ConfigOverride works through system propertirs it is not suitable for parallel tests. You need custom support inside your application: store embedded db credentials in some ThreadLocal variable and application should lookup it on startup and use if custom data available.
Eddie Xie
@oeddyo
does that mean I can't use DropwizardAppExtension<HttpServerConfiguration> any more since it loads from a yml file? or is there any way to override db credential programmatically?
Vyacheslav Rusakov
@xvik
there is always a way to do something programmatically. It will just be specific to your exact application. Just add a new condition somewhere (if someLookup.getUrl != null then use it else use url from configuration)

does that mean I can't use DropwizardAppExtension<HttpServerConfiguration> any more since it loads from a yml file

It's not a problem, in dropwizard you always have control how configuration is applied to code and always can modify it

Eddie Xie
@oeddyo

sorry I should've asked this better.

So my question really is for writing an extension using DropwizardAppExtension and dynamically set database (with embededPostgres). In the extension I'll construct a dropwizard app, and then for each test class I'll have a different port for postgres so they don’t conflict with each other.

Then let's say there are two test classes A, B uses this extension. So in A, the system property of database.url will be set to pg://A. When A starts, A will set the system property "dw.database.url" to "pg://A"

and when B starts, B will sets it to "pg://B". However A didn’t knonw and will keep using "pg://B" which causes problems when run in parallel.

So I guess this is where the confusion comes from. I think there might be one possibility and would like to hear what you think:

I would like to not use the same system property for A and B. Maybe "A.dw.database.url" and "B.dw.database.url". But I need to let DW know that it’s no longer "dw.database.url" that it should read DB settings from

Vyacheslav Rusakov
@xvik
mmm! i just thought! there is a way to overcome property limitation!
ConfigOverride maps configuration properties to system properties with custom prefix (dw. by default). And you can(!!!) change this prefix!