2016-04-15 6 views
0

Ich arbeite derzeit in einem CI-Flow mit Jenkins, die Mokka-Tests gegen ein Nodejs Server-Backend auslöst.Mocha-End-Test vor dem Abschluss aller Tests

Für einige Reassong Xunit Test Reporter arbeitete nicht mit Jenkins. Die Datei test-resul.xml wurde leer und der Job versagte. Wir konnten es durch Laufen Laufen bringen:

npm install mocha-jenkins-reporter 

direkt vor dem Trigger-Test unten gezeigt:

JUNIT_REPORT_PATH=test_report.xml JUNIT_REPORT_STACK=1 NODE_ENV=test node ./node_modules/.bin/mocha --globals * --reporter mocha-jenkins-reporter --no-colors 

Jetzt bin ich ein Teilergebnis bekommen, wie aus irgendeinem Grunde nicht alle Tests laufen . Sie stoppen mitten in der Testsuite ohne irgendeine Nachricht oder Fehlermeldung. Ich habe auch bemerkt, dass das XML erzeugt fehlt das Wurzelelement schließen Tag. Ich arbeitete um, dass durch Ausführen von:

echo '</testsuites>' >> test-result.xml 

Zusätzlich zu, dass, ich habe während der Prüfung der Ausführung der Speicherverbrauch Spitzen bemerkt. Dies ist die npm Ausgabe installieren, dieser Schritt ist der erste Schritt dieses Jobs:

+ npm -v 
3.8.6 
+ npm install 
npm WARN deprecated [email protected]: security/injection issue with limit/offset fixed in 3.17.0 
npm WARN deprecated [email protected]: Grunt needs your help! See https://github.com/gruntjs/grunt/issues/1403. 
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to [email protected]^4.0.0 as soon as possible. 
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade 
npm WARN deprecated [email protected]: graceful-fs version 3 and before will fail on newer node releases. Please update to [email protected]^4.0.0 as soon as possible. 

> [email protected] install /home/jenkins/workspace/Rufus_Test_DEV/node_modules/ws 
> (node-gyp rebuild 2> builderror.log) || (exit 0) 


> [email protected] postinstall /home/jenkins/workspace/Rufus_Test_DEV 
> echo 'To generate a new actionhero project, run "node ./node_modules/.bin/actionhero generate"' 

To generate a new actionhero project, run "node ./node_modules/.bin/actionhero generate" 
[email protected] /home/jenkins/workspace/Rufus_Test_DEV 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected].3 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | `-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| | `-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | `-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | `-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | `-- [email protected] 
| | | +-- [email protected] 
| | | | `-- [email protected] 
| | | +-- [email protected] 
| | | | +-- [email protected] 
| | | | `-- [email protected] 
| | | | `-- [email protected] 
| | | |  `-- [email protected] 
| | | `-- [email protected] 
| | `-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| |  `-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | `-- [email protected] 
| | | `-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
+-- [email protected] 
+-- [email protected] 
+-- [email protected] 
| `-- [email protected] 
+-- [email protected]2.71.0 invalid 
| +-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | +-- [email protected] 
| | | +-- [email protected] 
| | | | `-- [email protected] 
| | | +-- [email protected] 
| | | `-- [email protected] 
| | +-- [email protected] 
| | | `-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | +-- [email protected] 
| | | | `-- [email protected] 
| | | `-- [email protected] 
| | `-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | +-- [email protected] 
| | | `-- [email protected] 
| | `-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | | `-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | +-- [email protected] 
| | | | `-- [email protected] 
| | | `-- [email protected] 
| | `-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| | `-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| +-- [email protected] 
| `-- [email protected] 
+-- [email protected] 
| `-- [email protected] 
| +-- [email protected] 
| | +-- [email protected] 
| | | `-- [email protected] 
| | | `-- [email protected] 
| | `-- [email protected] 
| `-- [email protected] 
`-- [email protected] 
    +-- [email protected] 
    `-- [email protected] 

npm WARN [email protected] No license field. 

Antwort

1

Es scheint wahrscheinlich, dass die Speicherspitzen ein smoking gun sind - Sie sind mehr als entweder eine Ressource-Quote und jämmerlich, oder stürzt einfach ab. Dies scheint durch die erstellte partielle Datei bestätigt zu werden - Dateien, die wörtlich in der Mitte eines Stückes enden, sind ein starker Indikator für einen Crash oder einen Force-Kill.

Ich benutze ActionHero selbst, und es verwendet sehr wenig Speicher. Sequelize ist der Hauptteil seiner Verwendung und selbst dann ist es selten, dass ich mehr als 180 MB RAM auf einem Produktions-API-Knoten verwende. Sie waren nicht genau darüber informiert, wie groß Ihr "Memory-Spike" ist, aber ich würde mit einer Untersuchung beginnen, die genau angibt, wie viel Ihr Prozess verwendet und wie es zugewiesen wird. Es gibt viele Tools dafür, aber ich würde vorschlagen, etwas wie StrongLoop, PM2, NewRelic oder Ruxit zu verwenden, nur weil es Ihnen helfen wird, es schnell zu finden. Für all diese Tools stehen kostenlose oder Testoptionen zur Verfügung.

Darüber hinaus können Sie einige Untersuchungen durchführen, indem Sie die Tests einzeln ausführen. Wenn Sie mocha aufrufen, können Sie eine Testsuite zur Ausführung übergeben

Schließlich, wenn Sie Bash als Ihre Shell verwenden, versuchen Sie, die --globals * als Test zu entfernen. Bash erweitert das vor der Ausführung von Mocha und ersetzt es durch eine Liste von Dateien im aktuellen Arbeitsverzeichnis. Wenn sich herausstellt, dass etwas weggeworfen wird, können Sie es in Anführungszeichen setzen oder eine mocha.opts Datei erstellen. Hier ist meins, nur als ein Beispiel:

--recursive 
--reporter spec 
--timeout 15000 
--ignore-leaks 
--slow 3000 
--globals api,assert 
--require test/bootstrap 
test 

Beachten Sie, dass Befehlszeilenargumente opts-Dateieinstellungen überschreiben können. Deshalb habe ich --reporter spec hier - das reduziert meine Eingabe, um mocha manuell in meiner lokalen Entwicklungsumgebung auszuführen (ich kann einfach mocha mit überhaupt keinen params ausführen). Sie können den Reporter dennoch auf den gewünschten CI-Stack setzen.

+0

In der Tat sieht es definitiv wie ein Ressourcenallokationsproblem aus. Danke für die Tipps zu den Profiling-Tools, ich bin jetzt dran, sie zu testen und ich komme mit dem zurück, was ich gefunden habe, und wenn dies der Grund ist, akzeptiere deine Antwort. Danke für die tolle und schnelle Antwort. –

+0

Hey Chad, eine andere Sache, ich führe dies auf einem Docker-Container, weißt du, ob es in Ordnung ist, npm zu installieren, jedes Build zu bauen? Ist dies die empfohlene Einstellung oder sollte ich diese Abhängigkeiten auf das ursprüngliche Docker-Image übertragen? –

+1

Wenn Sie sich in einem Docker-Container befinden, stoßen Sie möglicherweise in Ihrer Verwaltungsebene auf ein festes Speicherlimit. Die meisten Docker-Manager wie Kube, Mesos, ECS, Rancher usw. haben diese. Versuchen Sie es zu erhöhen. Und ja, es ist in Ordnung, jeden Build auszuführen, aber normalerweise möchten Sie stattdessen 'npm update' ausführen. Das installiert fehlende Pakete und verarbeitet alle erforderlichen Updates. 'npm install' installiert nur die Installation. –

Verwandte Themen