From 69eff6a0f83b6ab27605851393f791e55231be6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Janis=20Daniel=20Da=CC=88hne?=
 <janis.daehne2@student.uni-halle.de>
Date: Mon, 29 Jul 2019 19:16:14 +0200
Subject: [PATCH] - removed max lines to read/write in favor of max characters
 limit

---
 i18n/en.ts                                    | 15 +---
 i18n/i18nRoot.ts                              | 15 +---
 .../helpers/tests/testServerHints.tsx         | 54 -------------
 .../consolePanel/consolePanelHeaderBar.tsx    | 81 +------------------
 .../consolePanel/consolePanelView.tsx         | 11 +++
 .../testServerSettingsView.tsx                | 74 -----------------
 src/constants.ts                              |  2 +-
 src/helpers/convertersAndTransformers.ts      |  2 +
 .../globalSystemSettingsReducer.ts            |  3 -
 src/types/systemSettings.ts                   |  4 -
 src/types/testResults.ts                      | 12 +++
 src/types/testsAndTestProtocol.ts             | 12 +++
 12 files changed, 45 insertions(+), 240 deletions(-)

diff --git a/i18n/en.ts b/i18n/en.ts
index 6551b34d..0d7097a5 100644
--- a/i18n/en.ts
+++ b/i18n/en.ts
@@ -250,6 +250,7 @@ export const lang_en: LangObj = {
   "Test-runner version": "Test-runner version",
   "Used timeout in ms": "Used timeout in ms",
   "Used compile timeout in ms": "Used compile timeout in ms",
+  "Used character limit" : "Used character limit",
 
   "Arguments": "Arguments",
   "unknown/ignored line": "unknown/ignored line",
@@ -275,12 +276,8 @@ export const lang_en: LangObj = {
   "Input": "Input",
   "Output": "Output",
   "Program": "Program",
-  "The test protocol contained too many lines..." : "The test protocol contained too many lines...",
-  "The stderr (program error output) contains more than (or equal to)" : "The stderr (program error output) contains more than (or equal to)",
-  "The stdout (program output) contains more than (or equal to)" : "The stdout (program output) contains more than (or equal to)",
-  "The stdin (test input lines) contains more than (or equal to)" : "The stdin (test input lines) contains more than (or equal to)",
-  "lines. All lines after the" : "lines. All lines after the",
-  "-th are just dropped (technical reasons)." : "-th are just dropped (technical reasons).",
+  "The test protocol exceeded the character limit and was truncated. However your test can still pass because character limit is only used to limit the memory used to store the test result. New lines are counted as 4 characters. There are some characters (~100) reserved for header data." : "The test protocol exceeded the character limit and was truncated. However your test can still pass because character limit is only used to limit the memory used to store the test result. New lines are counted as 4 characters. There are some characters (~100) reserved for header data.",
+
   "Test content read timeout" : "Test content read timeout",
   "Exit code mismatch" : "Exit code mismatch",
   "Compare files mismatch" : "Compare files mismatch",
@@ -307,15 +304,9 @@ export const lang_en: LangObj = {
   "Test-Server Limits" : "Test-Server Limits",
   "Setting" : "Setting",
 
-  "Max. lines to read": "Max. lines to read",
-  "Max. error lines to read": "Max. error lines to read",
-  "Max. lines to write": "Max. lines to write",
   "Max. tests with one request": "Max. tests with one request",
 
   "The max time the user program is allowed to run in ms" : "The max time the user program is allowed to run in ms",
-  "The max lines to read from the user program output (stdout). All following lines are ignored": "The max lines to read from the user program output (stdout). All following lines are ignored",
-  "The max lines to read from the user program error output (stderr). All following lines are ignored": "The max lines to read from the user program error output (stderr). All following lines are ignored",
-  "The max lines to write to the user program (stdin). All other lines are ignored": "The max lines to write to the user program (stdin). All other lines are ignored",
   "If one runs multiple tests this is the number of tests that are actually run with one requests. If there are tests left one must issue a new requests to run all tests": "If one runs multiple tests this is the number of tests that are actually run with one requests. If there are tests left one must issue a new requests to run all tests",
 
 
diff --git a/i18n/i18nRoot.ts b/i18n/i18nRoot.ts
index c6c137aa..926b10c3 100644
--- a/i18n/i18nRoot.ts
+++ b/i18n/i18nRoot.ts
@@ -253,6 +253,7 @@ export interface LangObj {
   "Test-runner version": string
   "Used timeout in ms": string
   "Used compile timeout in ms": string
+  "Used character limit": string
 
   "Arguments": string,
   "unknown/ignored line": string
@@ -278,13 +279,7 @@ export interface LangObj {
   "Input": string
   "Output": string
   "Program": string
-  "The test protocol contained too many lines...": string
-
-  "The stderr (program error output) contains more than (or equal to)": string
-  "The stdout (program output) contains more than (or equal to)": string
-  "The stdin (test input lines) contains more than (or equal to)": string
-  "lines. All lines after the": string
-  "-th are just dropped (technical reasons).": string
+  "The test protocol exceeded the character limit and was truncated. However your test can still pass because character limit is only used to limit the memory used to store the test result. New lines are counted as 4 characters. There are some characters (~100) reserved for header data.": string
 
   "Test content read timeout": string
   "Exit code mismatch": string
@@ -312,15 +307,9 @@ export interface LangObj {
   "Test-Server Limits" : string
   "Setting" : string
 
-  "Max. lines to read": string
-  "Max. error lines to read": string
-  "Max. lines to write": string
   "Max. tests with one request": string
 
   "The max time the user program is allowed to run in ms": string
-  "The max lines to read from the user program output (stdout). All following lines are ignored": string
-  "The max lines to read from the user program error output (stderr). All following lines are ignored": string
-  "The max lines to write to the user program (stdin). All other lines are ignored": string
   "If one runs multiple tests this is the number of tests that are actually run with one requests. If there are tests left one must issue a new requests to run all tests": string
 
   "This value is overwritten by the test-server setting timeout in ms (hardTimeoutInMs) which is the max time the user program can run": string
diff --git a/src/components/helpers/tests/testServerHints.tsx b/src/components/helpers/tests/testServerHints.tsx
index 32cc97c8..02b7f442 100644
--- a/src/components/helpers/tests/testServerHints.tsx
+++ b/src/components/helpers/tests/testServerHints.tsx
@@ -99,60 +99,6 @@ class TestServerHints extends React.Component<Props & ButtonProps, any> {
                   </Table.Cell>
                 </Table.Row>
 
-                <Table.Row>
-                  <Table.Cell>
-                    {getI18n(this.props.langId, "Max. lines to read")}
-                  </Table.Cell>
-                  <Table.Cell>
-                    {
-                      this.props.testServerPublicSettings.maxLinesToRead
-                    }
-                  </Table.Cell>
-                  <Table.Cell>
-                    <span>
-                    {
-                      getI18n(this.props.langId, "The max lines to read from the user program output (stdout). All following lines are ignored")
-                    }
-                  </span>
-                  </Table.Cell>
-                </Table.Row>
-
-                <Table.Row>
-                  <Table.Cell>
-                    {getI18n(this.props.langId, "Max. error lines to read")}
-                  </Table.Cell>
-                  <Table.Cell>
-                    {
-                      this.props.testServerPublicSettings.maxErrLinesToRead
-                    }
-                  </Table.Cell>
-                  <Table.Cell>
-                     <span>
-                    {
-                      getI18n(this.props.langId, "The max lines to read from the user program error output (stderr). All following lines are ignored")
-                    }
-                  </span>
-                  </Table.Cell>
-                </Table.Row>
-
-                <Table.Row>
-                  <Table.Cell>
-                    {getI18n(this.props.langId, "Max. lines to write")}
-                  </Table.Cell>
-                  <Table.Cell>
-                    {
-                      this.props.testServerPublicSettings.maxLinesToWrite
-                    }
-                  </Table.Cell>
-                  <Table.Cell>
-                     <span>
-                    {
-                      getI18n(this.props.langId, "The max lines to write to the user program (stdin). All other lines are ignored")
-                    }
-                  </span>
-                  </Table.Cell>
-                </Table.Row>
-
                 <Table.Row>
                   <Table.Cell>
                     {getI18n(this.props.langId, "Max. RAM in kb")}
diff --git a/src/components/sites/doExerciseSite/consolePanel/consolePanelHeaderBar.tsx b/src/components/sites/doExerciseSite/consolePanel/consolePanelHeaderBar.tsx
index dd618659..8f678e81 100644
--- a/src/components/sites/doExerciseSite/consolePanel/consolePanelHeaderBar.tsx
+++ b/src/components/sites/doExerciseSite/consolePanel/consolePanelHeaderBar.tsx
@@ -65,47 +65,6 @@ class consolePanelHeaderBar extends React.Component<Props, any> {
 
   render(): JSX.Element {
 
-
-    // noinspection TsLint
-    let hasMaxErrorLinesHit: boolean = false
-    // noinspection TsLint
-    let hasMaxTestInputLinesHit: boolean = false
-    // noinspection TsLint
-    let hasMaxProgramOutputLinesHit: boolean = false
-
-    const minMaxLinesValue = Math.min(this.props.testServerPublicSettings.maxErrLinesToRead,
-                                      this.props.testServerPublicSettings.maxLinesToWrite,
-                                      this.props.testServerPublicSettings.maxLinesToRead
-    )
-
-    // noinspection TsLint
-    if (this.props.test && this.props.test.result && this.props.test.result.protocol.length >= minMaxLinesValue && minMaxLinesValue !== testServerPublicSettingsNotAvailableValue) {
-
-
-      const numMaxErrorLinesHit: number = this.props.test.result.protocol.reduce(
-        (p, c) => p + (startsWith(c.trim(), TestProtocol.errorPrefix)
-                       ? 1
-                       : 0),
-        0
-      )
-      const numMaxTestInputLinesHit: number = this.props.test.result.protocol.reduce(
-        (p, c) => p + (startsWith(c.trim(), TestProtocol.inputSign)
-                       ? 1
-                       : 0),
-        0
-      )
-      const numMaxProgramOutputLinesHit: number = this.props.test.result.protocol.reduce(
-        (p, c) => p + (startsWith(c.trim(), TestProtocol.outputSign)
-                       ? 1
-                       : 0),
-        0
-      )
-
-      hasMaxErrorLinesHit = numMaxErrorLinesHit >= this.props.testServerPublicSettings.maxErrLinesToRead
-      hasMaxTestInputLinesHit = numMaxTestInputLinesHit >= this.props.testServerPublicSettings.maxLinesToWrite
-      hasMaxProgramOutputLinesHit = numMaxProgramOutputLinesHit >= this.props.testServerPublicSettings.maxLinesToRead
-    }
-
     return (
       <div className="flexed">
         {
@@ -276,7 +235,7 @@ class consolePanelHeaderBar extends React.Component<Props, any> {
             <div className="v-centered flexed-no-wrap too-much-text-hidden">
 
               {
-                (hasMaxErrorLinesHit || hasMaxProgramOutputLinesHit || hasMaxTestInputLinesHit) &&
+                this.props.test.result.characterLimitExceeded &&
                 <MyPopup
                   trigger={
                     <div className="mar-right-half hoverable">
@@ -285,43 +244,7 @@ class consolePanelHeaderBar extends React.Component<Props, any> {
                   }
                   content={
                     <div>
-                      <div>{getI18n(this.props.langId, "The test protocol contained too many lines...")}</div>
-                      {
-                        hasMaxTestInputLinesHit &&
-                        <div>{
-                          `${getI18n(this.props.langId,
-                                     "The stdin (test input lines) contains more than (or equal to)"
-                          )} ${this.props.testServerPublicSettings.maxErrLinesToRead} ${getI18n(this.props.langId,
-                                                                                                "lines. All lines after the"
-                          )} ${this.props.testServerPublicSettings.maxErrLinesToRead} ${getI18n(this.props.langId,
-                                                                                                "-th are just dropped (technical reasons)."
-                          )}`
-                        }</div>
-                      }
-                      {
-                        hasMaxProgramOutputLinesHit &&
-                        <div>{
-                          `${getI18n(this.props.langId,
-                                     "The stdout (program output) contains more than (or equal to)"
-                          )} ${this.props.testServerPublicSettings.maxErrLinesToRead} ${getI18n(this.props.langId,
-                                                                                                "lines. All lines after the"
-                          )} ${this.props.testServerPublicSettings.maxErrLinesToRead} ${getI18n(this.props.langId,
-                                                                                                "-th are just dropped (technical reasons)."
-                          )}`
-                        }</div>
-                      }
-                      {
-                        hasMaxErrorLinesHit &&
-                        <div>{
-                          `${getI18n(this.props.langId,
-                                     "The stderr (program error output) contains more than (or equal to)"
-                          )} ${this.props.testServerPublicSettings.maxErrLinesToRead} ${getI18n(this.props.langId,
-                                                                                                "lines. All lines after the"
-                          )} ${this.props.testServerPublicSettings.maxErrLinesToRead} ${getI18n(this.props.langId,
-                                                                                                "-th are just dropped (technical reasons)."
-                          )}`
-                        }</div>
-                      }
+                      <div>{getI18n(this.props.langId, "The test protocol exceeded the character limit and was truncated. However your test can still pass because character limit is only used to limit the memory used to store the test result. New lines are counted as 4 characters. There are some characters (~100) reserved for header data.")}</div>
                     </div>
                   }
                   wide="very"
diff --git a/src/components/sites/doExerciseSite/consolePanel/consolePanelView.tsx b/src/components/sites/doExerciseSite/consolePanel/consolePanelView.tsx
index 7f449663..bd433f26 100644
--- a/src/components/sites/doExerciseSite/consolePanel/consolePanelView.tsx
+++ b/src/components/sites/doExerciseSite/consolePanel/consolePanelView.tsx
@@ -335,6 +335,17 @@ class ConsolePanelView extends React.Component<Props, any> {
                           </Table.Cell>
                         </Table.Row>
 
+                        <Table.Row>
+                        <Table.Cell>
+                          {getI18n(this.props.langId, "Used character limit")}
+                        </Table.Cell>
+                        <Table.Cell>
+                          {
+                            this.props.test.result.characterLimitUsed
+                          }
+                        </Table.Cell>
+                      </Table.Row>
+
                         <Table.Row>
                           <Table.Cell>
                             {getI18n(this.props.langId, "Test-server version")}
diff --git a/src/components/sites/systemSettingsSite/testServerSettingsView.tsx b/src/components/sites/systemSettingsSite/testServerSettingsView.tsx
index ea841bf5..a3930e50 100644
--- a/src/components/sites/systemSettingsSite/testServerSettingsView.tsx
+++ b/src/components/sites/systemSettingsSite/testServerSettingsView.tsx
@@ -144,80 +144,6 @@ class TestServerSettingsView extends React.Component<Props, any> {
 
               </Form.Group>
 
-
-              <Form.Group widths="equal">
-
-                {
-                  //max lines to read
-                }
-                <Form.Field>
-
-                  <div className="form-field-label-with-icon">
-                    <label>
-                      {
-                        getI18n(this.props.langId, "Max. lines to read")
-                      }
-                    </label>
-                    <HelpPopup wide
-                               className="mar-left-half"
-                               defaultText={getI18n(this.props.langId,
-                                                    "The max lines to read from the user program output (stdout). All following lines are ignored"
-                               )}
-                    />
-
-                  </div>
-                  <MaterialInput type="number" value={this.props.testServerPublicSettings.maxLinesToRead} disabled
-                  />
-                </Form.Field>
-
-                {
-                  //max err lines to read
-                }
-                <Form.Field>
-
-                  <div className="form-field-label-with-icon">
-                    <label>
-                      {
-                        getI18n(this.props.langId, "Max. error lines to read")
-                      }
-                    </label>
-                    <HelpPopup wide
-                               className="mar-left-half"
-                               defaultText={getI18n(this.props.langId,
-                                                    "The max lines to read from the user program error output (stderr). All following lines are ignored"
-                               )}
-                    />
-
-                  </div>
-                  <MaterialInput type="number" value={this.props.testServerPublicSettings.maxErrLinesToRead} disabled
-                  />
-                </Form.Field>
-
-                {
-                  //max lines to write
-                }
-                <Form.Field>
-
-                  <div className="form-field-label-with-icon">
-                    <label>
-                      {
-                        getI18n(this.props.langId, "Max. lines to write")
-                      }
-                    </label>
-                    <HelpPopup wide
-                               className="mar-left-half"
-                               defaultText={getI18n(this.props.langId,
-                                                    "The max lines to write to the user program (stdin). All other lines are ignored"
-                               )}
-                    />
-
-                  </div>
-                  <MaterialInput type="number" value={this.props.testServerPublicSettings.maxLinesToWrite} disabled
-                  />
-                </Form.Field>
-
-              </Form.Group>
-
               <Form.Group widths="equal">
 
                 <Form.Field>
diff --git a/src/constants.ts b/src/constants.ts
index 37777aa8..8f7053a7 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -13,7 +13,7 @@ import Logger from './helpers/logger'
  * y - breaking changes / new features
  * z - fixes, small changes
  */
-export const versionString = '2.4.8'
+export const versionString = '2.4.9'
 
 
 /**
diff --git a/src/helpers/convertersAndTransformers.ts b/src/helpers/convertersAndTransformers.ts
index 400b68e3..b81bbf9f 100644
--- a/src/helpers/convertersAndTransformers.ts
+++ b/src/helpers/convertersAndTransformers.ts
@@ -644,6 +644,8 @@ export function _storedTestResultToTestResult(storedResult: StoredTestResultFrom
     timeForUserProgram: storedResult.timeForUserProgram,
     timeoutInMsUsed: storedResult.timeoutInMsUsed,
     compileTimeoutInMsUsed: storedResult.compileTimeoutInMsUsed,
+    characterLimitExceeded: storedResult.characterLimitExceeded,
+    characterLimitUsed: storedResult.characterLimitUsed
   }
 }
 
diff --git a/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts b/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts
index c7ca9b06..83b48592 100644
--- a/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts
+++ b/src/state/reducers/globalSystemSettings/globalSystemSettingsReducer.ts
@@ -103,9 +103,6 @@ export const initial: State = {
     hardCompileTimeoutInMs: testServerPublicSettingsNotAvailableValue,
     hardMemoryLimitInKb: testServerPublicSettingsNotAvailableValue,
     hardDiskSpaceLimitInKb: testServerPublicSettingsNotAvailableValue,
-    maxErrLinesToRead: testServerPublicSettingsNotAvailableValue,
-    maxLinesToRead: testServerPublicSettingsNotAvailableValue,
-    maxLinesToWrite: testServerPublicSettingsNotAvailableValue,
     maxNumberOfTestsWithOneRequest: testServerPublicSettingsNotAvailableValue
   },
   clickedOnServerMessage: false,
diff --git a/src/types/systemSettings.ts b/src/types/systemSettings.ts
index bde32c56..b958ba4e 100644
--- a/src/types/systemSettings.ts
+++ b/src/types/systemSettings.ts
@@ -137,9 +137,5 @@ export interface TestServerPublicSettings {
   readonly hardMemoryLimitInKb: number
   readonly hardDiskSpaceLimitInKb: number
 
-  readonly maxLinesToRead: number
-  readonly maxErrLinesToRead: number
-  readonly maxLinesToWrite: number
-
   readonly maxNumberOfTestsWithOneRequest: number
 }
diff --git a/src/types/testResults.ts b/src/types/testResults.ts
index bd7b06e8..c323b6af 100644
--- a/src/types/testResults.ts
+++ b/src/types/testResults.ts
@@ -87,6 +87,18 @@ export interface StoredTestResultFromBackend {
    * can be null
    */
   readonly testServerVersion: string
+
+  /**
+   * true: the character limit was exceeded and the protocol was cut
+   * false: not
+   */
+  readonly characterLimitExceeded: boolean
+
+  /**
+   * the db will only store a max of characters for test result protocol
+   * can be null for old results
+   */
+  readonly characterLimitUsed: number |null
 }
 
 export interface AssessmentForUserWithTestResults {
diff --git a/src/types/testsAndTestProtocol.ts b/src/types/testsAndTestProtocol.ts
index fd47a6f3..c7eeec8f 100644
--- a/src/types/testsAndTestProtocol.ts
+++ b/src/types/testsAndTestProtocol.ts
@@ -542,6 +542,18 @@ export interface TestAnswerFromBackend {
    * can be null
    */
   readonly testServerVersion: string
+
+  /**
+   * true: the character limit was exceeded and the protocol was cut
+   * false: not
+   */
+  readonly characterLimitExceeded: boolean
+
+  /**
+   * the db will only store a max of characters for test result protocol
+   * can be null for old results
+   */
+  readonly characterLimitUsed: number |null
 }
 
 
-- 
GitLab