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

Initial solution of Integration tests control. #185

Merged
merged 50 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e1ad209
Initial solution of Integration tests control.
miroslavpojer Apr 12, 2024
8b61557
Debugging file to identify the source of problem.
miroslavpojer Apr 12, 2024
15b9fcd
Merge branch 'master' into feature/new-sbt-integration-tests
miroslavpojer Apr 12, 2024
79512f9
Debugging file to identify the source of problem.
miroslavpojer Apr 12, 2024
6ee894e
Debugging file to identify the source of problem.
miroslavpojer Apr 12, 2024
eb35565
Debugging file to identify the source of problem.
miroslavpojer Apr 12, 2024
107ba53
Debugging file to identify the source of problem.
miroslavpojer Apr 12, 2024
46ff776
Debugging file to identify the source of problem.
miroslavpojer Apr 12, 2024
297057f
Fix review comments.
miroslavpojer Apr 15, 2024
5c62f86
Added description of Integration test controls.
miroslavpojer Apr 15, 2024
464118b
Retested solution and removed testDB alias.
miroslavpojer Apr 15, 2024
559c24a
Merge branch 'refs/heads/master' into feature/new-sbt-integration-tests
miroslavpojer May 2, 2024
d0174fa
Fixing hardcoded version values for jacoco report GH Action.
miroslavpojer May 2, 2024
18c155f
Experiment with no string value of version
miroslavpojer May 2, 2024
d3bb3bb
Experiment with no string value of version
miroslavpojer May 2, 2024
3bb9810
Experiment with no string value of version
miroslavpojer May 2, 2024
4b91afe
Experiment with no string value of version
miroslavpojer May 2, 2024
d869448
Return back the hardcoded value.
miroslavpojer May 2, 2024
cb82439
Fixed tag String in README.md.
miroslavpojer May 2, 2024
3be6f06
Fixed typo in README.md.
miroslavpojer May 2, 2024
fd6e50f
Implemented solution of IntegrationTest control.
miroslavpojer May 2, 2024
f075b04
Renamed new command name from 'integrationTest' to 'testIT' to avoid …
miroslavpojer May 3, 2024
3f29f23
Add support to measure jacoco code coverage for unit and IT tests in …
miroslavpojer May 3, 2024
e2992b5
Update yml files for server module. Added new testIT command and jaco…
miroslavpojer May 3, 2024
bc9c3ae
- Updated sbt rc aliases.
miroslavpojer May 3, 2024
69c618f
- Fix the jacoco call row.
miroslavpojer May 3, 2024
3c22636
- Fix the jacoco call row.
miroslavpojer May 3, 2024
6d300a0
- Update to more specific name of three steps.
miroslavpojer May 3, 2024
6170ac1
- Fix typo.
miroslavpojer May 3, 2024
c4e0206
- Removed `++Version` from README. file.
miroslavpojer May 7, 2024
57b8dbe
- Removed `++Version` from README. file.
miroslavpojer May 7, 2024
08171ba
- Removed `++Version` from README. file.
miroslavpojer May 7, 2024
a5b5b61
- Removed IT tag from non IT test.
miroslavpojer May 7, 2024
b838cfc
- Update `testBD` alias as proposed in review. Now `sbt testDB` is on…
miroslavpojer May 7, 2024
3a72ba4
Merge branch 'refs/heads/master' into feature/new-sbt-integration-tests
miroslavpojer May 7, 2024
3f3ff49
- Previous solution replaced by new idea based on test class names.
miroslavpojer May 10, 2024
715e9d1
- Updated README.md to fit with new solution.
miroslavpojer May 10, 2024
5fd43e7
- Updated texts in README.md to fit current implementation.
miroslavpojer May 10, 2024
1e6e642
- Applying defined naming rules for cps projects to support QA Type s…
miroslavpojer May 11, 2024
bfc194d
- Update of README.md file to check all sbt command examples (test, t…
miroslavpojer May 11, 2024
27820ec
- Review of build.yml and add small description improvement.
miroslavpojer May 11, 2024
d0b5266
- Removed local solution for test file name scan. Will be solved by e…
miroslavpojer May 11, 2024
e54443a
- Removed not needed matrix definition.
miroslavpojer May 13, 2024
1db0673
- Separated server jobs in build.yml.
miroslavpojer May 14, 2024
acc44df
- Removed matrix from build.yml.
miroslavpojer May 14, 2024
939d266
- Test suffixes migrates to plural version.
miroslavpojer May 15, 2024
d36e6af
- Removed forgotten test env definition.
miroslavpojer May 16, 2024
ed76338
- Renamed one last test file following naming conventions.
miroslavpojer May 21, 2024
b962730
Merge branch 'refs/heads/master' into feature/new-sbt-integration-tests
miroslavpojer May 23, 2024
b177140
- Applied changes after merge master.
miroslavpojer May 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ jobs:
run: sbt flywayMigrate

- name: Build and run tests
run: sbt "project server" ++${{matrix.scala}} test doc
run: sbt "project server" ++${{matrix.scala}} testIT doc
6 changes: 3 additions & 3 deletions .github/workflows/jacoco_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Add coverage to PR
Copy link
Collaborator

@lsulak lsulak Apr 22, 2024

Choose a reason for hiding this comment

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

Btw, is this unit test coverage or combined? What does sbt jacoco do?

If it runs sbt test under the hood, which excludes the ITs (I assume this is what's happening, judging by the output of sbt jacoco on my localhost), then it might make sense to update the naming/titles/sentences in the jacoco YAML files - so that things are a bit more explicit & bot comments generated in PRs would reflect that.

Also, please rename this file to something like jacoco_check_agent.yml (we have _server already so it would be more obvious)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here is the overview:

  • agent - unit test only (no IT/DB test in module)
  • model - unit test only (no IT/DB test in module)
  • database - db test only (no IT/Unit test in module)
  • server - integration test only (no Unit/DB test in module)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes but the naming of the files (potentially also steps) still deserves improving, such as this jacoco_check.yml

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, I am open to proposals.
Current naming is trying to be self-descriptive.

Copy link
Collaborator

Choose a reason for hiding this comment

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

so jacoco_check.yml -> jacoco_check_agent.yml / jacoco_check_agent_model.yml

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It could be done, yes. Byt why?
I would suggest to do future review here after project fixes issue with multiple java version need.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, let's address this outside of this PR.

if: steps.jacocorun.outcome == 'success'
id: jacoco-agent
uses: madrapps/jacoco-report@${{ env.jaCocoReportVersion }}
uses: madrapps/jacoco-report@v1.6.1
with:
name: agent-jacoco-report
paths: ${{ github.workspace }}/agent/target/jvm-${{ env.scalaShort12 }}/jacoco/report/jacoco.xml
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Add coverage to PR
if: steps.jacocorun.outcome == 'success'
id: jacoco-model
uses: madrapps/jacoco-report@${{ env.jaCocoReportVersion }}
uses: madrapps/jacoco-report@v1.6.1
with:
name: model-jacoco-report
paths: ${{ github.workspace }}/model/target/jvm-${{ env.scalaShort12 }}/jacoco/report/jacoco.xml
Expand Down Expand Up @@ -118,4 +118,4 @@ jobs:
}
}

core.setFailed('JaCoCo test coverage report generation failed, and related PR comments were updated.');
core.setFailed('JaCoCo test coverage report generation failed, and related PR comments were updated.');
5 changes: 5 additions & 0 deletions .sbtrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Test run control
alias test=; testOnly -l IntegrationTest
alias testDB=; testOnly -t IntegrationTest
alias testIT=; testOnly -- -t IntegrationTest
alias testAll=; testOnly
8 changes: 0 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,6 @@ lazy val database = (projectMatrix in file("database"))
},
libraryDependencies ++= Dependencies.databaseDependencies,
(Compile / compile) := ((Compile / compile) dependsOn printScalaVersion).value,
test := {}
): _*
)
.jvmPlatform(scalaVersions = Seq(Versions.serviceScalaVersion))

lazy val dbTest = taskKey[Unit]("Launch DB tests")

dbTest := {
println("Running DB tests")
(database.jvm(Versions.serviceScalaVersion) / Test / test).value
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package za.co.absa.atum.database.runs

import za.co.absa.atum.tags.IntegrationTestTag
import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString
import za.co.absa.balta.classes.setter.CustomDBType
Expand All @@ -38,7 +39,7 @@ class CreateOrUpdateAdditionalDataTest extends DBTestSuite{
|""".stripMargin
)

test("Partitioning and AD present, delete & re-insert, and also 'ignore' of AD records performed") {
test("Partitioning and AD present, delete & re-insert, and also 'ignore' of AD records performed", IntegrationTestTag) {

table("runs.partitionings").insert(
add("partitioning", partitioning)
Expand Down Expand Up @@ -102,7 +103,7 @@ class CreateOrUpdateAdditionalDataTest extends DBTestSuite{
}
}

test("Partitioning and AD present, new AD records inserted, nothing backed up") {
test("Partitioning and AD present, new AD records inserted, nothing backed up", IntegrationTestTag) {

table("runs.partitionings").insert(
add("partitioning", partitioning)
Expand Down Expand Up @@ -168,7 +169,7 @@ class CreateOrUpdateAdditionalDataTest extends DBTestSuite{
}
}

test("Partitioning and AD present, but no new AD records were backed-up or inserted, no changes detected") {
test("Partitioning and AD present, but no new AD records were backed-up or inserted, no changes detected", IntegrationTestTag) {

table("runs.partitionings").insert(
add("partitioning", partitioning)
Expand Down Expand Up @@ -216,7 +217,7 @@ class CreateOrUpdateAdditionalDataTest extends DBTestSuite{
assert(table("runs.additional_data_history").count(add("fk_partitioning", fkPartitioning)) == 0)
}

test("Partitioning not present, no action taken") {
test("Partitioning not present, no action taken", IntegrationTestTag) {

val inputADToInsert = CustomDBType(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package za.co.absa.atum.database.runs

import za.co.absa.atum.tags.IntegrationTestTag
import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString

Expand Down Expand Up @@ -51,7 +52,7 @@ class CreatePartitioningIfNotExistsTest extends DBTestSuite{
|""".stripMargin
)

test("Partitioning created") {
test("Partitioning created", IntegrationTestTag) {
val partitioningID = function(fncCreatePartitioningIfNotExists)
.setParam("i_partitioning", partitioning)
.setParam("i_by_user", "Fantômas")
Expand Down Expand Up @@ -91,7 +92,7 @@ class CreatePartitioningIfNotExistsTest extends DBTestSuite{
assert(!flowsResult.hasNext)
}
}
test("Partitioning created with parent partitioning that already exists") {
test("Partitioning created with parent partitioning that already exists", IntegrationTestTag) {
val parentPartitioningID = function(fncCreatePartitioningIfNotExists)
.setParam("i_partitioning", parentPartitioning)
.setParam("i_by_user", "Albert Einstein")
Expand Down Expand Up @@ -126,7 +127,7 @@ class CreatePartitioningIfNotExistsTest extends DBTestSuite{
)
}

test("Partitioning already exists") {
test("Partitioning already exists", IntegrationTestTag) {
val partitioningID = function(fncCreatePartitioningIfNotExists)
.setParam("i_partitioning", partitioning)
.setParam("i_by_user", "Fantômas")
Expand Down Expand Up @@ -156,7 +157,7 @@ class CreatePartitioningIfNotExistsTest extends DBTestSuite{
)
}

test("Partitioning exists, but parent is added") {
test("Partitioning exists, but parent is added", IntegrationTestTag) {
val partitioningID = function(fncCreatePartitioningIfNotExists)
.setParam("i_partitioning", partitioning)
.setParam("i_by_user", "Fantômas")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package za.co.absa.atum.database.runs

import za.co.absa.atum.tags.IntegrationTestTag
import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString

Expand Down Expand Up @@ -52,7 +53,7 @@ class GetPartitioningAdditionalDataTest extends DBTestSuite{
|""".stripMargin
)

test("Get partitioning additional data returns additional data for partitioning with additional data") {
test("Get partitioning additional data returns additional data for partitioning with additional data", IntegrationTestTag) {
table("runs.partitionings").insert(
add("partitioning", partitioning1)
.add("created_by", "Joseph")
Expand Down Expand Up @@ -119,7 +120,7 @@ class GetPartitioningAdditionalDataTest extends DBTestSuite{

}

test("Get partitioning additional data should return no records for partitioning without additional data") {
test("Get partitioning additional data should return no records for partitioning without additional data", IntegrationTestTag) {
table("runs.partitionings").insert(
add("partitioning", partitioning2)
.add("created_by", "Joseph")
Expand All @@ -142,7 +143,7 @@ class GetPartitioningAdditionalDataTest extends DBTestSuite{
}
}

test("Get partitioning additional data should return error status code on non existing partitioning") {
test("Get partitioning additional data should return error status code on non existing partitioning", IntegrationTestTag) {
val partitioning = JsonBString(
"""
|{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

package za.co.absa.atum.database.runs

import za.co.absa.atum.tags.IntegrationTestTag
import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString
import za.co.absa.balta.classes.setter.CustomDBType

class GetPartitioningMeasuresTest extends DBTestSuite {
private val fncGetPartitioningMeasures = "runs.get_partitioning_measures"

test("Get partitioning measures should return partitioning measures for partitioning with measures") {
test("Get partitioning measures should return partitioning measures for partitioning with measures", IntegrationTestTag) {
val partitioning = JsonBString(
"""
|{
Expand Down Expand Up @@ -85,7 +86,7 @@ class GetPartitioningMeasuresTest extends DBTestSuite {
}
}

test("Get partitioning measures should return error status code on non existing partitioning") {
test("Get partitioning measures should return error status code on non existing partitioning", IntegrationTestTag) {
val partitioning = JsonBString(
"""
|{
Expand All @@ -108,7 +109,7 @@ class GetPartitioningMeasuresTest extends DBTestSuite {
}
}

test("Get partitioning measures should return no data status code on partitioning without measures") {
test("Get partitioning measures should return no data status code on partitioning without measures", IntegrationTestTag) {
val partitioning = JsonBString(
"""
|{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package za.co.absa.atum.database.runs

import org.postgresql.util.PSQLException
import za.co.absa.atum.tags.IntegrationTestTag
import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString

Expand Down Expand Up @@ -69,7 +70,7 @@ class IsPartitioningValidTest extends DBTestSuite {
|""".stripMargin
)

test("Partitioning is valid (strict check)") {
test("Partitioning is valid (strict check)", IntegrationTestTag) {
function(fncIsPartitioningValid)
.setParam("i_partitioning", partitioningValid)
.execute { queryResult =>
Expand All @@ -82,7 +83,7 @@ class IsPartitioningValidTest extends DBTestSuite {
}
}

test("Partitioning is valid but has null values (strict check)") {
test("Partitioning is valid but has null values (strict check)", IntegrationTestTag) {
val caught = intercept[PSQLException](
function(fncIsPartitioningValid)
.setParam("i_partitioning", partitioningValidWithNullValues)
Expand All @@ -94,7 +95,7 @@ class IsPartitioningValidTest extends DBTestSuite {
)
}

test("Partitioning is valid but has null values (non-strict check)") {
test("Partitioning is valid but has null values (non-strict check)", IntegrationTestTag) {
function(fncIsPartitioningValid)
.setParam("i_partitioning", partitioningValidWithNullValues)
.setParam("i_strict_check", false)
Expand All @@ -108,7 +109,7 @@ class IsPartitioningValidTest extends DBTestSuite {
}
}

test("Partitioning is invalid") {
test("Partitioning is invalid", IntegrationTestTag) {
val caught = intercept[PSQLException](
function(fncIsPartitioningValid)
.setParam("i_partitioning", partitioningInvalid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package za.co.absa.atum.database.runs

import za.co.absa.atum.tags.IntegrationTestTag
import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString
import za.co.absa.balta.classes.setter.CustomDBType
Expand All @@ -38,7 +39,7 @@ class UpdateExistingAdditionalDataTest extends DBTestSuite{
|""".stripMargin
)

test("Partitioning and AD present, multiple AD records backed up") {
test("Partitioning and AD present, multiple AD records backed up", IntegrationTestTag) {

table("runs.partitionings").insert(
add("partitioning", partitioning)
Expand Down Expand Up @@ -121,7 +122,7 @@ class UpdateExistingAdditionalDataTest extends DBTestSuite{

}

test("Partitioning and AD present, but the input AD are the same as in DB, no backup") {
test("Partitioning and AD present, but the input AD are the same as in DB, no backup", IntegrationTestTag) {

table("runs.partitionings").insert(
add("partitioning", partitioning)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package za.co.absa.atum.database.runs

import za.co.absa.atum.tags.IntegrationTestTag
import za.co.absa.balta.DBTestSuite
import za.co.absa.balta.classes.JsonBString

Expand Down Expand Up @@ -164,23 +165,23 @@ class ValidatePartitioningTest extends DBTestSuite {
|""".stripMargin
)

test("Partitioning is valid (strict check)") {
test("Partitioning is valid (strict check)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValid)
.execute { queryResult =>
assert(!queryResult.hasNext)
}
}

test("Partitioning is valid, even when keys have whitespaces (without them they would be duplicated)") {
test("Partitioning is valid, even when keys have whitespaces (without them they would be duplicated)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValidWhitespacesInKeys)
.execute { queryResult =>
assert(!queryResult.hasNext)
}
}

test("Partitioning is valid but has null values (strict check)") {
test("Partitioning is valid but has null values (strict check)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValidWithNullValues)
.execute { queryResult =>
Expand All @@ -194,7 +195,7 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is valid, but one key doesn't have a value (strict check)") {
test("Partitioning is valid, but one key doesn't have a value (strict check)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValidMissingValue)
.execute { queryResult =>
Expand All @@ -212,7 +213,7 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is valid, but one key doesn't have a value (non-strict check)") {
test("Partitioning is valid, but one key doesn't have a value (non-strict check)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValidMissingValue)
.setParam("i_strict_check", false)
Expand All @@ -221,7 +222,7 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is valid, but keys don't correspond to values (non-strict check)") {
test("Partitioning is valid, but keys don't correspond to values (non-strict check)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValidValuesNotCorrespondToKeys)
.setParam("i_strict_check", false)
Expand All @@ -230,7 +231,7 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is valid, but keys don't correspond to values (strict check)") {
test("Partitioning is valid, but keys don't correspond to values (strict check)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValidValuesNotCorrespondToKeys)
.execute { queryResult =>
Expand All @@ -248,7 +249,7 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is invalid, incompatible version") {
test("Partitioning is invalid, incompatible version", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningInvalidIncompatibleVersion)
.execute { queryResult =>
Expand All @@ -262,15 +263,15 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is valid, but it has redundant attribute") {
test("Partitioning is valid, but it has redundant attribute", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningValidRedundantAttribute)
.execute { queryResult =>
assert(!queryResult.hasNext)
}
}

test("Partitioning is invalid, valid JSON but incorrect structure (attribute missing)") {
test("Partitioning is invalid, valid JSON but incorrect structure (attribute missing)", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningInvalidBadJSONStructure1)
.execute { queryResult =>
Expand All @@ -284,7 +285,7 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is invalid, duplicated partition keys") {
test("Partitioning is invalid, duplicated partition keys", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningInvalidDuplicatedKeys)
.execute { queryResult =>
Expand All @@ -300,7 +301,7 @@ class ValidatePartitioningTest extends DBTestSuite {
}
}

test("Partitioning is invalid, multiple problems") {
test("Partitioning is invalid, multiple problems", IntegrationTestTag) {
function(fncValidatePartitioning)
.setParam("i_partitioning", partitioningInvalidMultipleProblems)
.execute { queryResult =>
Expand Down
Loading
Loading