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

first DAO test with h2 db setup #15

Merged
merged 2 commits into from
Aug 23, 2018

Conversation

julienledem
Copy link
Member

No description provided.

build.gradle Outdated
@@ -16,9 +16,6 @@ repositories {
mavenCentral()
}

if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This build must be run with Java 8")
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? I have java 9

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we can remove. This check was more for guarding against compatibility changes and ensure we build with a stable version (but java 9 is fairly stable).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using Java 9 with this project going forward?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Java 9 is fairly stable anyways. Also comes with convenient factory methods for collections!

build.gradle Outdated
@@ -31,6 +28,7 @@ dependencies {
testCompile 'io.dropwizard:dropwizard-testing:1.3.5'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.19.0'
testCompile 'com.h2database:h2:1.4.197'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we want to test alternative DB types that we currently don't support? The DB schema is currently defined using postgres. We also config postgres at runtime and don't allow for other DB types (at least currently).

Copy link
Member

@wslulciuc wslulciuc Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, overlooked testCompile. What are your thoughts on using testcontainers instead of H2?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping that h2 would be compatible enough. I did not know about testcontainers, but as long as the setup is integrated in the test (with a Rule) then it looks great. We just need to verify it what dependencies are (docker installed etc). The fewer the better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a dependency on docker, which does add one more thing to get up and running. That said, for integration tests, that'd be fine and expected.

import marquez.api.Owner;
import marquez.db.dao.fixtures.DAOSetup;

public class TestOwnerDAO {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I prefer starting test classes with the name of the class under test: <class>Test. For example, OwnerDAOTest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM.

public class TestOwnerDAO {

@ClassRule
public static final DAOSetup daoSetup = new DAOSetup();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we can simplify the app setup with:

   @ClassRule
   static final DropwizardAppRule<MarquezConfiguration> RULE =
     new DropwizardAppRule<MarquezConfiguration>(
       MarquezApplication.class,
       ResourceHelpers.resourceFilePath("config.yaml"));

source: http://dropwizard.readthedocs.io/en/stable/manual/testing.html

Copy link
Member

@wslulciuc wslulciuc Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we decided to use testcontainers, the rule would be defined simply as:

@Rule
public PostgreSQLContainer postgres = new PostgreSQLContainer();

source: SimplePostgreSQLTest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DAOSetup class is trying to simplify further the DropwizardAppRule, since we know the Config and App classes, have a config file etc. I started with the DARule.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


@Test
public void testUpdateOwner() {
ownerDAO.insert(new Owner("Amaranta"));
Copy link
Contributor

@ashulmanWeWork ashulmanWeWork Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should verify the result and/or assert that it was inserted.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed :) The DAO doesn't have a "get" yet so I stopped there. It doesn't fail which mean that the db is setup properly. I wanted to have the DB setup to bootstrap DAO testing.

@sshah-wework
Copy link
Contributor

Is the idea that we merge this as the empty test suite and we can work on filling in with tests in future PRs?

@julienledem
Copy link
Member Author

Yes, the idea was to bootstrap DAO test by setting up the DB

@sshah-wework
Copy link
Contributor

Ok perfect.

Copy link
Contributor

@sshah-wework sshah-wework left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@wslulciuc wslulciuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Note: I'm testing out using testcontainer outlined in #20, but not a blocker to merge this PR :)

return jdbi.onDemand(classT);
}
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@sshah-wework sshah-wework merged commit 0b898b8 into MarquezProject:master Aug 23, 2018
sshah-wework pushed a commit that referenced this pull request Aug 23, 2018
phixMe pushed a commit that referenced this pull request Nov 12, 2020
* fix position of network graph and search bar, adjust padding for row with datasets

* change legend position to fixed
wslulciuc pushed a commit that referenced this pull request Nov 14, 2020
* Add DropWizard Jackson Object Mapper

* Add JobType

* Add JsonUtils.newObjectMapper factory method

* Add ModelGenerator.newIdWithBound helper function
wslulciuc pushed a commit that referenced this pull request Dec 3, 2020
* Add __init__.py for installation

* Up the version
wslulciuc pushed a commit that referenced this pull request Dec 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants