kopia lustrzana https://github.com/jupyterhub/repo2docker
				
				
				
			Updated app.py to make sure that images can start notebook servers
Includes an update of conftest.py file to check that the container is running with jupyter notebook in all the builders.pull/343/head
							rodzic
							
								
									8adc402a04
								
							
						
					
					
						commit
						89686833c0
					
				|  | @ -103,10 +103,10 @@ class Repo2Docker(Application): | |||
| 
 | ||||
|         Use a key-value pair, with the key being the volume source & | ||||
|         value being the destination volume. | ||||
|          | ||||
|         Both source and destination can be relative. Source is resolved  | ||||
| 
 | ||||
|         Both source and destination can be relative. Source is resolved | ||||
|         relative to the current working directory on the host, and | ||||
|         destination is resolved relative to the working directory of the  | ||||
|         destination is resolved relative to the working directory of the | ||||
|         image - ($HOME by default) | ||||
|         """, | ||||
|         config=True | ||||
|  | @ -504,7 +504,7 @@ class Repo2Docker(Application): | |||
|         client = docker.from_env(version='auto') | ||||
|         if not self.run_cmd: | ||||
|             port = str(self._get_free_port()) | ||||
| 
 | ||||
|             self.port = port | ||||
|             run_cmd = ['jupyter', 'notebook', '--ip', '0.0.0.0', | ||||
|                        '--port', port] | ||||
|             ports = {'%s/tcp' % port: port} | ||||
|  |  | |||
|  | @ -11,6 +11,8 @@ success. | |||
| import os | ||||
| import pipes | ||||
| import shlex | ||||
| import requests | ||||
| import time | ||||
| 
 | ||||
| import pytest | ||||
| import yaml | ||||
|  | @ -30,7 +32,39 @@ def make_test_func(args): | |||
|     def test(): | ||||
|         app = Repo2Docker() | ||||
|         app.initialize(args) | ||||
|         app.start() | ||||
|         if app.run_cmd: | ||||
|             # verify test, run it | ||||
|             app.start() | ||||
|             return | ||||
|         # no run_cmd given, starting notebook server | ||||
|         app.run = False | ||||
|         app.start()  # This just build the image and does not run it. | ||||
|         container = app.start_container() | ||||
|         port = app.port | ||||
|         # wait a bit for the container to be ready | ||||
|         container_url = 'http://localhost:%s/api' % port | ||||
|         # give the container a chance to start | ||||
|         time.sleep(1) | ||||
|         try: | ||||
|             # try a few times to connect | ||||
|             success = False | ||||
|             for i in range(1, 4): | ||||
|                 container.reload() | ||||
|                 assert container.status == 'running' | ||||
|                 try: | ||||
|                     info = requests.get(container_url).json() | ||||
|                 except Exception as e: | ||||
|                     print("Error: %s" % e) | ||||
|                     time.sleep(i * 3) | ||||
|                 else: | ||||
|                     print(info) | ||||
|                     success = True | ||||
|                     break | ||||
|             assert success, "Notebook never started in %s" % container | ||||
|         finally: | ||||
|             # stop the container | ||||
|             container.stop() | ||||
|             app.wait_for_container(container) | ||||
|     return test | ||||
| 
 | ||||
| 
 | ||||
|  | @ -68,6 +102,13 @@ class LocalRepo(pytest.File): | |||
|                 './verify', | ||||
|             ], | ||||
|         ) | ||||
|         yield Repo2DockerTest( | ||||
|             self.fspath.basename, self, | ||||
|             args=[ | ||||
|                 '--appendix', 'RUN echo "appendix" > /tmp/appendix', | ||||
|                 self.fspath.dirname, | ||||
|             ], | ||||
|         ) | ||||
| 
 | ||||
| 
 | ||||
| class RemoteRepoList(pytest.File): | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Gladys Nalvarte
						Gladys Nalvarte