start-test-server.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2018-2022 Elyra Authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import { exec, spawn } from 'child_process';
  17. import fs from 'fs';
  18. import path from 'path';
  19. const config = path.join(__dirname, '..', 'tests', 'test-config.py');
  20. const jupyter = exec(`jupyter lab --config ${config}`);
  21. const CONTAINER_NAME = 'minio_test';
  22. const docker = spawn('docker', [
  23. 'run',
  24. '--rm',
  25. '--name',
  26. CONTAINER_NAME,
  27. '-p',
  28. '9000:9000',
  29. 'minio/minio',
  30. 'server',
  31. '/data'
  32. ]);
  33. const logDir = path.join(__dirname, '..', 'build', 'cypress-tests');
  34. const jupyterLog = fs.createWriteStream(path.join(logDir, 'jupyter.log'));
  35. jupyter.stderr?.pipe(jupyterLog);
  36. const dockerLog = fs.createWriteStream(path.join(logDir, 'docker.log'));
  37. docker.stderr.pipe(dockerLog);
  38. const handleTeardown = (): void => {
  39. spawn('docker', ['kill', CONTAINER_NAME]);
  40. process.exit();
  41. };
  42. process.on('SIGINT', handleTeardown);
  43. process.on('SIGTERM', handleTeardown);