Skip to content

Commit

Permalink
TimeoutContinuationTest
Browse files Browse the repository at this point in the history
  • Loading branch information
adibaba committed Nov 18, 2019
1 parent bcf7eb3 commit e6cf15d
Show file tree
Hide file tree
Showing 5 changed files with 477 additions and 0 deletions.
69 changes: 69 additions & 0 deletions examples/TimeoutContinuationTest/TimeoutContinuationTest-A.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-markdown-task",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# Timeout continuation test\n",
"\n",
"Tests, if the grading of all ngbrader-tests continue, even if there is a timeout during one single test. \n",
"The test has to be auto-graded. \n",
"\n",
"One test in one file should fail. \n",
"The overall grading should result in 40 points."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-autograde-visible",
"locked": true,
"points": 10,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"%maven org.junit.jupiter:junit-jupiter-api:5.3.1\n",
"import org.junit.jupiter.api.Assertions;\n",
"\n",
"System.out.println(\"Testing A\");\n",
"\n",
"Assertions.assertTrue(true);"
]
}
],
"metadata": {
"celltoolbar": "Create Assignment",
"kernelspec": {
"display_name": "Java",
"language": "java",
"name": "java"
},
"language_info": {
"codemirror_mode": "java",
"file_extension": ".jshell",
"mimetype": "text/x-java-source",
"name": "Java",
"pygments_lexer": "java",
"version": "11.0.4+11-post-Ubuntu-1ubuntu218.04.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

69 changes: 69 additions & 0 deletions examples/TimeoutContinuationTest/TimeoutContinuationTest-B.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-markdown-task",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# Timeout continuation test\n",
"\n",
"Tests, if the grading of all ngbrader-tests continue, even if there is a timeout during one single test. \n",
"The test has to be auto-graded. \n",
"\n",
"One test in one file should fail. \n",
"The overall grading should result in 40 points."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-autograde-visible",
"locked": true,
"points": 10,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"%maven org.junit.jupiter:junit-jupiter-api:5.3.1\n",
"import org.junit.jupiter.api.Assertions;\n",
"\n",
"System.out.println(\"Testing B\");\n",
"\n",
"Assertions.assertTrue(true);"
]
}
],
"metadata": {
"celltoolbar": "Create Assignment",
"kernelspec": {
"display_name": "Java",
"language": "java",
"name": "java"
},
"language_info": {
"codemirror_mode": "java",
"file_extension": ".jshell",
"mimetype": "text/x-java-source",
"name": "Java",
"pygments_lexer": "java",
"version": "11.0.4+11-post-Ubuntu-1ubuntu218.04.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

201 changes: 201 additions & 0 deletions examples/TimeoutContinuationTest/TimeoutContinuationTest-C-Fails.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-markdown-task",
"locked": true,
"schema_version": 3,
"solution": false
}
},
"source": [
"# Timeout continuation test\n",
"\n",
"Tests, if the grading of all ngbrader-tests continue, even if there is a timeout during one single test. \n",
"The test has to be auto-graded. \n",
"\n",
"One test in one file should fail. \n",
"The overall grading should result in 40 points."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-code",
"locked": false,
"schema_version": 3,
"solution": true
}
},
"outputs": [],
"source": [
"// BEGIN SOLUTION\n",
"// END SOLUTION\n",
"int timeoutSecondsPass = 1;\n",
"int timeoutSecondsFail = 400;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-a74effbecac8c29b",
"locked": true,
"schema_version": 3,
"solution": false
}
},
"outputs": [],
"source": [
"boolean doSomething(int timeoutSeconds) throws java.lang.InterruptedException {\n",
" long time = System.currentTimeMillis();\n",
" long end = time + (timeoutSeconds * 1000);\n",
" System.out.println(\"\");\n",
" while(System.currentTimeMillis() < end) {\n",
" System.out.print(((end-time)/1000) + \" \");\n",
" Thread.sleep(5000);\n",
" time = System.currentTimeMillis();\n",
" }\n",
" System.out.println(\"\");\n",
" return true;\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-autograde-visible-1",
"locked": true,
"points": 1,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"%maven org.junit.jupiter:junit-jupiter-api:5.3.1\n",
"import org.junit.jupiter.api.Assertions;\n",
"\n",
"System.out.println(\"Testing C\");\n",
"\n",
"System.out.println(\"Waiting \" + timeoutSecondsPass + \" seconds\");\n",
"Assertions.assertTrue(doSomething(timeoutSecondsPass));\n",
"System.out.println(\"Test 1 successfully completed\");"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-autograde-visible-2",
"locked": true,
"points": 1,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"System.out.println(\"Waiting \" + timeoutSecondsPass + \" seconds\");\n",
"Assertions.assertTrue(doSomething(timeoutSecondsPass));\n",
"System.out.println(\"Test 2 successfully completed\");"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-autograde-visible-3",
"locked": true,
"points": 1,
"schema_version": 3,
"solution": false
}
},
"outputs": [],
"source": [
"System.out.println(\"Waiting \" + timeoutSecondsFail + \" seconds\");\n",
"Assertions.assertTrue(doSomething(timeoutSecondsFail));\n",
"System.out.println(\"Test 3 successfully completed\");"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-autograde-visible-4",
"locked": true,
"points": 1,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"System.out.println(\"Waiting \" + timeoutSecondsPass + \" seconds\");\n",
"Assertions.assertTrue(doSomething(timeoutSecondsPass));\n",
"System.out.println(\"Test 4 successfully completed\");"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-autograde-visible-5",
"locked": true,
"points": 1,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"System.out.println(\"Waiting \" + timeoutSecondsPass + \" seconds\");\n",
"Assertions.assertTrue(doSomething(timeoutSecondsPass));\n",
"System.out.println(\"Test 5 successfully completed\");"
]
}
],
"metadata": {
"celltoolbar": "Create Assignment",
"kernelspec": {
"display_name": "Java",
"language": "java",
"name": "java"
},
"language_info": {
"codemirror_mode": "java",
"file_extension": ".jshell",
"mimetype": "text/x-java-source",
"name": "Java",
"pygments_lexer": "java",
"version": "11.0.4+11-post-Ubuntu-1ubuntu218.04.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

Loading

0 comments on commit e6cf15d

Please sign in to comment.