Skip to content

Split testing into its own project #235

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

Merged
merged 13 commits into from
May 28, 2021
Merged

Conversation

schveiguy
Copy link
Collaborator

This PR splits out all the integration-based testing into its own test project. Only a few tests were true unittests and did not require a full database connection to perform the test (which is a natural consequence of creating a database connection library).

The rest have been added to a subproject called integration-tests. You can run these via dub run :integration-tests

At this point, we are using vibe exclusively for the tests. We still need to perform the integration tests with Phobos sockets, that will be a future enhancement.

Also, the troublesome app.d has been moved to its own project called testconn (it needs testing as well).

@schveiguy
Copy link
Collaborator Author

ping @SingingBush

@@ -97,28 +93,6 @@ Prepared prepareFunction(Connection conn, string name, int numArgs)
return prepare(conn, sql);
}

///
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note, this unittest was not actually documented. And even if it were, it would have been terrible documentation (using scopedCn for the connection which is completely internal).

@schveiguy
Copy link
Collaborator Author

TODO: have to investigate spacing. My editor I used for a lot of this didn't obey the .editorconfig. grrrr.....

Copy link

@SingingBush SingingBush left a comment

Choose a reason for hiding this comment

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

Are checks for version(DoCoreTests) are redundant now? There was a bunch of version checks that may not be needed with the way the code is now structured.

@SingingBush
Copy link

There are two files in my branch that I believe should be copied into this pull request (with tweaks):

  • integration-tests/docker-compose.yml
  • integration-tests/README.md

It should make it trivial for people to check the project out and run the tests with no prior setup (except to have docker) and a readme file specific to the test project means that the readme in the root of the project can be used to just put information that's relevant to people that want to use mysql-native as a dependency.

@schveiguy
Copy link
Collaborator Author

I might need your help on docker, I'm not well-versed in it.

@schveiguy
Copy link
Collaborator Author

Are checks for version(DoCoreTests) are redundant now?

Yeah, I think so. Working through the version logic, if you define MYSQLN_CORE_TESTS as opposed to MYSQLN_TESTS, the only test that is run is the basic connection test. Which is pretty useless.

I'm thinking we should get rid of these version statements, and rely on unit-threaded to allow running of individual tests. But maybe as a future PR, don't want to distract too much from the sheer copy-paste-ness of this PR.

@schveiguy
Copy link
Collaborator Author

So I've run into a weird problem. With dub, if you have a dependency with an optional dependency, you can't optionally depend on that optional dependency.

I added a second config to omit the dependency on vibe-core, and it still pulls in vibe-core.

I think I will need to create a third project that tests vibe, and make the vibe-core dependency optional. Ugh...

@SingingBush
Copy link

So I've run into a weird problem. With dub, if you have a dependency with an optional dependency, you can't optionally depend on that optional dependency.

I added a second config to omit the dependency on vibe-core, and it still pulls in vibe-core.

I think I will need to create a third project that tests vibe, and make the vibe-core dependency optional. Ugh...

isn't it something you can sort with configurations? like in this: https://github.com/SingingBush/mysql-native/blob/pipeline/integration_testing/tests/dub.sdl

dependency "mysql-native" path="../"

configuration "default" {
    subConfiguration "mysql-native" "library"
}

configuration "use-vibe" {
    subConfiguration "mysql-native" "library"
    dependency "vibe-core" version="~>1.16.0" optional=false
}

@schveiguy
Copy link
Collaborator Author

No, it doesn't work. I'm going to file a dub bug, but I have a crappy workaround at the moment. You'll see.

@schveiguy
Copy link
Collaborator Author

@SingingBush why aren't we running windows/macos integration tests? Are those not possible?

@schveiguy
Copy link
Collaborator Author

Added the dub issue: dlang/dub#2136

@schveiguy
Copy link
Collaborator Author

@SingingBush I've noticed that the "Install dependencies on Ubuntu" never gets run for integration tests. Any idea why? It seems like it's not needed anyway.

@SingingBush
Copy link

@SingingBush I've noticed that the "Install dependencies on Ubuntu" never gets run for integration tests. Any idea why? It seems like it's not needed anyway.

good point that may not be needed anywhere. I think it used to be needed for vibe. Can probably come out

@schveiguy schveiguy force-pushed the splittests branch 2 times, most recently from a1c2fc7 to 2e4cb37 Compare May 26, 2021 12:24
@schveiguy
Copy link
Collaborator Author

why aren't we running windows/macos integration tests? Are those not possible?

testing confirms, windows and macos do not support docker, and therefore cannot run an instance of mysql or mariadb. This is a shame, but I'm OK with it for now.

@schveiguy
Copy link
Collaborator Author

schveiguy commented May 26, 2021

@SingingBush can you take a look at the docker file and integration test readme that I just added? I have not tested the docker image, I don't really know how to use docker. Note that I used the user/password in the default testConnectionStr.txt file for convenience (this is most likely what they will want to use).

@SingingBush
Copy link

that looks fine, cheers. After this is all merged I'll use it anyway so any issues then I'll push a commit.

@schveiguy schveiguy force-pushed the splittests branch 4 times, most recently from 8543e5d to 71055c2 Compare May 26, 2021 15:52
@schveiguy
Copy link
Collaborator Author

Pretty satisfied with this. The only thing I need to figure out is how to restructure the dub file so that it doesn't spit out tons of warnings.

@SingingBush
Copy link

Pretty satisfied with this. The only thing I need to figure out is how to restructure the dub file so that it doesn't spit out tons of warnings.

Use silenceWarnings in build requirements. in dub.json this would be done with:

    "buildRequirements": [
		"silenceWarnings"
    ]

@schveiguy
Copy link
Collaborator Author

OK, I found another solution using "sourceLibrary", now the ugly warnings only appear in integration-tests, which I'm not so worried about.

I think this is ready to merge.

BTW, @SingingBush feel free to open a PR to add your name to the author/copyright

@schveiguy schveiguy marked this pull request as ready for review May 27, 2021 14:03
(mostly for people who want to run actions on their local branches)
@schveiguy
Copy link
Collaborator Author

@SingingBush can you explain the "dub upgrade" portions of the workflow? We don't need to dub upgrade anything, because there is no checked-in dub.selections.json file. So I'm confused why this is there.

I'm also not clear what the caching thing is, but I can probably ask webfreak about that on discord.

@SingingBush
Copy link

@SingingBush can you explain the "dub upgrade" portions of the workflow? We don't need to dub upgrade anything, because there is no checked-in dub.selections.json file. So I'm confused why this is there.

I'm also not clear what the caching thing is, but I can probably ask webfreak about that on discord.

Feel free to remove the dub upgrade bit. Sooner this is merged the better. Can then perhaps get both #187 and #220 merged in and do another release before you rebase/merge #214 and bump the major release version.

@schveiguy
Copy link
Collaborator Author

schveiguy commented May 28, 2021

I checked with webfreak, and the dub upgrade is somewhat misnamed, as it caches the entire .dub folder for subsequent runs, in addition to running dub upgrade, as if you were storing it locally on your PC. A good test would be to run it with and without the dub upgrade to see how much time it saves.

I'll leave it there for now, it's not hurting anything (though I think it never runs the second dub upgrade Edit: it does run on windows).

@schveiguy schveiguy merged commit 323ee58 into mysql-d:master May 28, 2021
@schveiguy schveiguy deleted the splittests branch May 28, 2021 16:04
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.

2 participants