Skip to content

Feature/haskell testing - #20

Merged
OZoneGuy merged 59 commits into
masterfrom
feature/haskell-testing
Aug 22, 2021
Merged

Feature/haskell testing#20
OZoneGuy merged 59 commits into
masterfrom
feature/haskell-testing

Conversation

@OZoneGuy

Copy link
Copy Markdown
Contributor

Overview

Added support for Haskell testing.

Addresses #6.

Needed to create a new PR due a branch rename.

This change is a

  • Bug fix
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will change existing functionality)
  • Documentation update

Description

  • Added support for Haskell
  • Created Haskell Dockerfile
  • Created haskell_entry.sh
  • Using stack to install required package and compile program
  • Improved writeTestCaseToSuiteFile to allow for different languages

Motivation/Links

Notes and problems:

  • Currently, the docker container will fail due to bad volume option. It passes a relative path, while docker does not accept relative paths and requires an absolute path. Unsure how could this be fixed since I don't know how will the file system look in production.
  • Needed to remove all ulimit commands from the entry script as it was breaking stack. It said it needed at least 70 MiB to run. And there was a problem with the -u command.

How was this tested?

I ran the tests using the REST API, and it behaved as expected.

Todos

  • Ensure unit tests pass
  • Update documentation for changes (if necessary)
  • Delete stale branch after merge

OZoneGuy added 30 commits July 25, 2021 01:26
Wrote the docker file used to create the image for Haskell testing
The entry script for the Haskell testing container
Added values in `application-local.yml`
Added variables in `DockerService.java`

Note: Most of the changes in `DockerService.java` is from the fromatter
Commented out all `ulimit` commands in `haskell_entry.sh`

There were resource problems when running the container.
1. `-u` option was problematic
2. The command said it requires at least 70MiB to run

More investigation is required to find proper resource limits.
Made the stack install a common command so it won't need to be rerun for every
image
Only `Add . .` and `ENTRYPOINT ...` are the "unique" layers
Fixed timeout issue for new layers that take a long time to build

Increased `docker.build.timeout` to 300s from 10s
Added missing argument to `String.format` call
Allow the user to set the suite file name to any name, as long as it is a valid
module name

Added `-main-is` option to `stack ghc` command call
Automatically add `import HUnit` to generated suite file

It is needed for all Haskell files, so best to automate it
Wrote the docker file used to create the image for Haskell testing
The entry script for the Haskell testing container
Added values in `application-local.yml`
Added variables in `DockerService.java`

Note: Most of the changes in `DockerService.java` is from the fromatter
Commented out all `ulimit` commands in `haskell_entry.sh`

There were resource problems when running the container.
1. `-u` option was problematic
2. The command said it requires at least 70MiB to run

More investigation is required to find proper resource limits.
Made the stack install a common command so it won't need to be rerun for every
image
Only `Add . .` and `ENTRYPOINT ...` are the "unique" layers
Fixed timeout issue for new layers that take a long time to build

Increased `docker.build.timeout` to 300s from 10s
Added missing argument to `String.format` call
Allow the user to set the suite file name to any name, as long as it is a valid
module name

Added `-main-is` option to `stack ghc` command call
Automatically add `import HUnit` to generated suite file

It is needed for all Haskell files, so best to automate it
OZoneGuy added 5 commits August 14, 2021 09:58
Removed `-u` option, doesn't work in container
Increased $PF_VIR_MEM, required for compilation
Increased $PF_MAX_FILE_SZ, required for compilation/linking

NOTE: We will probably need to increase $PF_VIR_MEM for prod, bigger programs
might require more memory to compile
Fixed wrong entry file name
Changed `Test.hs` in command back to `"$TEST_FILE_NAME"`

@benjaminkostiuk benjaminkostiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for all the changes, I managed to run it on my machine and it seems to work 👍 so that's great. The only hiccup is gonna be image size for Haskell down the road...we might have to create our own in alpine or something cause 4 GB is too much.

Could you also bootstrap a sample project + test cases for haskell for easy testing, similar to what I did for python? I'll push what I did and you can build it out a little maybe. Look in bootstrap_data.sql to get started.

Comment thread src/main/java/com/unityTest/testrunner/service/CodeService.java Outdated
Comment thread src/main/resources/runner/docker/haskell/haskell_entry.sh Outdated
Comment thread src/main/resources/runner/docker/haskell/haskell_entry.sh Outdated
Comment thread src/main/resources/runner/docker/haskell/Dockerfile Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread src/main/resources/runner/docker/haskell/Dockerfile Outdated
Comment thread src/main/resources/runner/docker/haskell/Dockerfile Outdated
Comment thread src/main/resources/runner/docker/haskell/haskell_entry.sh Outdated
Comment thread src/main/resources/runner/environments/reg.env Outdated
benjaminkostiuk and others added 9 commits August 19, 2021 14:38
Co-authored-by: Ben Kostiuk <kostiukb@mcmaster.ca>
Co-authored-by: Ben Kostiuk <kostiukb@mcmaster.ca>
Co-authored-by: Ben Kostiuk <kostiukb@mcmaster.ca>
Co-authored-by: Ben Kostiuk <kostiukb@mcmaster.ca>
Co-authored-by: Ben Kostiuk <kostiukb@mcmaster.ca>
Co-authored-by: Omar Alkersh <oalkersh@protonmail.com>
Co-authored-by: Omar Alkersh <oalkersh@protonmail.com>
Comment thread src/main/resources/runner/docker/haskell/Dockerfile
OZoneGuy and others added 4 commits August 22, 2021 00:59
Program now exits with code 1 if any test case failures and exit code 2 if there
are any runtime errors

Checking that number of errors and number of failures are 0

Before program used to exit with code 0 regardless of test results, now returns
the correct exit code on test failure
Return code 3 on compilation error and code 137, `TIMEOUT_ERROR`, on command timeout

Before it used to return runtime error or constraint error on compilation errors
Moved Haskell section under python and above Walkthrough
Updated the sample generated test file
@OZoneGuy

Copy link
Copy Markdown
Contributor Author

I am assuming everything is good now? If so, could you approve the PR.

// TODO;
break;
case HASKELL:
// TODO: Consider putting code in file and replacing function name and body into read string

@benjaminkostiuk benjaminkostiuk Aug 22, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this is necessary at this point. It's not exactly practical to make changes to.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am assuming everything is good now? If so, could you approve the PR.

Almost!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The suite template, should I save it with the Dockerfile and the entry script? Or should I create a new directory for it? If so, lmk where do want it.

And I think we should save the path in the application.yml file under docker.build.haskell.suite-template. Lmk if this sounds good or where do want it before I push the changes.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That's perfect!

Comment thread README.md Outdated
benjaminkostiuk and others added 3 commits August 21, 2021 21:31
Co-authored-by: Omar Alkersh <oalkersh@protonmail.com>
Storing the Haskell suite template in a text file for later read and formatting.

Easier management and more practical changes than using StringBuilder
@benjaminkostiuk
benjaminkostiuk self-requested a review August 22, 2021 23:01

@benjaminkostiuk benjaminkostiuk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You'll need to add the new suite-template property in application-test.yml for the automated tests to pass. Otherwise looks good! Feel free to squash and merge when ready.

Don't forget to give a little time for the Bump package version Actions script to finish after merging before deleting the branch.

@OZoneGuy
OZoneGuy merged commit 9a557e8 into master Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Feature or improvement priority:high High priority work item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test case support for Java & Haskell

3 participants