| 
									
										
										
										
											2023-06-20 16:00:55 -07:00
										 |  |  | #!/usr/bin/env bash
 | 
					
						
							| 
									
										
										
										
											2023-03-30 13:23:30 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Start the containerized repository and run ingest tests | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # shellcheck disable=SC2317  # Shellcheck complains that trap functions are unreachable... | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set -eux -o pipefail | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CONTAINER_NAME=unstructured-smoke-test | 
					
						
							| 
									
										
										
										
											2023-04-06 10:03:42 -07:00
										 |  |  | DOCKER_IMAGE="${DOCKER_IMAGE:-unstructured:dev}" | 
					
						
							| 
									
										
										
										
											2023-03-30 13:23:30 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | # Change to the root of the repository | 
					
						
							|  |  |  | SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | 
					
						
							|  |  |  | cd "$SCRIPT_DIR"/.. || exit 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | start_container() { | 
					
						
							|  |  |  |     echo Starting container "$CONTAINER_NAME" | 
					
						
							| 
									
										
										
										
											2023-04-06 10:03:42 -07:00
										 |  |  |     docker run -dt --rm --name "$CONTAINER_NAME" "$DOCKER_IMAGE" | 
					
						
							| 
									
										
										
										
											2023-03-30 13:23:30 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | await_container() { | 
					
						
							|  |  |  |     echo Waiting for container to start | 
					
						
							|  |  |  |     until [ "$(docker inspect -f '{{.State.Status}}' $CONTAINER_NAME)" == "running" ]; do | 
					
						
							|  |  |  |         sleep 1 | 
					
						
							|  |  |  |     done | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | stop_container() { | 
					
						
							|  |  |  |     echo Stopping container "$CONTAINER_NAME" | 
					
						
							|  |  |  |     docker stop "$CONTAINER_NAME" | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | start_container | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Regardless of test result, stop the container | 
					
						
							|  |  |  | trap stop_container EXIT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | await_container | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Run the tests | 
					
						
							| 
									
										
										
										
											2023-08-29 23:27:52 -07:00
										 |  |  | docker cp test_unstructured_ingest $CONTAINER_NAME:/home/notebook-user | 
					
						
							|  |  |  | docker exec -u root "$CONTAINER_NAME" /bin/bash -c "chown -R 1000:1000 /home/notebook-user/test_unstructured_ingest" | 
					
						
							|  |  |  | docker exec "$CONTAINER_NAME" /bin/bash -c "/home/notebook-user/test_unstructured_ingest/test-ingest-wikipedia.sh" | 
					
						
							| 
									
										
										
										
											2023-03-30 13:23:30 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | result=$? | 
					
						
							|  |  |  | exit $result |