Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Convert bootstrap shell and bat files to a common Python file. #208

Merged
merged 16 commits into from
Jun 6, 2023

Conversation

ScottBailey
Copy link
Contributor

@ScottBailey ScottBailey commented Jun 1, 2023

  • Convert bootstrap.sh file to python.
  • Update tests.
    • Added a step to clear the images to ensure testing always runs with a fresh test as well as testing the --release flag.
    • Added steps to further test cdt and leap versions and combos.
    • Added requirement for tests to be marked either destructive or safe.
    • Added slow marker for disabling tests in CI.
  • Update CI testing workflow.
    • Remove bootstrap command, allow tests to generate the image and container.
    • Added --run-destructive to pytest command so tests could be developed to execute non-ci or periodically only.
  • Update docs.
  • Rename Dockerfile.unix to Dockerfile.
  • Remove Dockerfile.win (it's a 1:1 duplicate of Dockerfile.unix).

Will close #202

@ScottBailey
Copy link
Contributor Author

@iamveritas Please review (run) OSX tests.

Copy link
Contributor

@mikelik mikelik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code is so pleasant to read now, thanks Scott.

However it seems, that if we have already existing image then running bootstrap.py doesn't change the leap version.

Example:

1st run works ok:
mikel@msi:~/repo/DUNE$ ./bootstrap.py --leap 3.2.2
[+] Building 320.3s (26/26) FINISHED                                                                                                    
(...) => => naming to docker.io/library/dunes                                                                                           0.0s 

mikel@msi:~/repo/DUNE$ ./dunes --version-all
Creating docker container [dunes_container]
DUNES v1.1.2
Listing... Done
leap/now 3.2.2 amd64 [installed,local]
Listing... Done
cdt/now 4.0.0-1 amd64 [installed,local]

# now the second run seems not to change leap version:
mikel@msi:~/repo/DUNE$ ./bootstrap.py --leap 3.2.3
[+] Building 291.3s (26/26) FINISHED                                                                                                    
(...)
 => => naming to docker.io/library/dunes                                                                                           0.0s 
mikel@msi:~/repo/DUNE$ ./dunes --version-all
DUNES v1.1.2
Listing... Done
leap/now 3.2.2 amd64 [installed,local]
Listing... Done
cdt/now 4.0.0-1 amd64 [installed,local]
mikel@msi:~/repo/DUNE$ 

In the second bootstrap.py I'm trying to change leap 3.2.2 to leap 3.2.3. However, old 3.2.2 is still installed.

/edit
Tested on Windows. It seems the same issue is for leap on Windows.
However --cdt on Windows worked properly.

bootstrap.bat Show resolved Hide resolved
bootstrap.py Outdated Show resolved Hide resolved
bootstrap.py Show resolved Hide resolved
@ScottBailey ScottBailey requested review from mikelik and iamveritas June 1, 2023 21:53
@ScottBailey
Copy link
Contributor Author

ScottBailey commented Jun 1, 2023

That code is so pleasant to read now, thanks Scott.

However it seems, that if we have already existing image then running bootstrap.py doesn't change the leap version.

/edit Tested on Windows. It seems the same issue is for leap on Windows. However --cdt on Windows worked properly.

I'm not sure you are describing a defect. A running container uses the image it's started with. That's not necessarily something we can or should change...

I have added tests to start multiple containers and test that they include the correct versions of leap and cdt.

@mikelik
Copy link
Contributor

mikelik commented Jun 2, 2023

However it seems, that if we have already existing image then running bootstrap.py doesn't change the leap version.

/edit Tested on Windows. It seems the same issue is for leap on Windows. However --cdt on Windows worked properly.

I'm not sure you are describing a defect. A running container uses the image it's started with. That's not necessarily something we can or should change...

You are right, bootstrap shouldn't change the existing container. I have checked this works as expected on Linux and Windows now - thanks.

…t more self contained in image bootstrap test.
@ScottBailey ScottBailey requested a review from mikelik June 2, 2023 15:50
This script tests that the bootstrap command can create an image with a given version.

This test contains resource intense tests that should NOT be run on every commit.
To disable during ci testing, add `-k "not non_ci"` to your pytest command (e.g. `pytest -k "not non_ci" tests`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To disable during ci testing, add `-k "not non_ci"` to your pytest command (e.g. `pytest -k "not non_ci" tests`)
To disable during ci testing, add `-k "not expensive"` to your pytest command (e.g. `pytest -k "not expensive" tests`)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is overcome by the latest change, I believe.

images = subprocess.check_output(['docker', 'images', '-q', repo_name], stderr=None, encoding='utf-8').strip().split('\n')
for myimg in images:
# pylint: disable=subprocess-run-check
subprocess.run(['docker', 'image', 'rm', myimg, '--force'], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, check=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is very dangerous for the user - it will remove all dunes images, even the running ones.
Remember, we are attaching those tests to the release as well.
I preferred the previous solution, where bootstrap.py had to be executed manually (or by CI script). And even if it was executed, it did not alter running images. What was the issue with it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A number of the existing tests are also destructive and will destroy a container. I believe the latest commit (with destructive marking) corrects this issue.

iamveritas

This comment was marked as duplicate.

Copy link

@iamveritas iamveritas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran python3 bootstrap.py on this PR's branch locally without errors.

Adding conftest.py to disable auto run of desctrictive and slow tests.
Updating workflows to run destructive tests, but not slow ones.
@ScottBailey ScottBailey requested a review from mikelik June 5, 2023 20:14
@ScottBailey ScottBailey mentioned this pull request Jun 5, 2023
docs/RELEASE.md Outdated Show resolved Hide resolved
tests/conftest.py Outdated Show resolved Hide resolved
@@ -107,7 +107,7 @@ $ echo "PATH=<LocationOfDUNES>:$PATH" >> .bashrc
If you want to rebuild the DUNES image pick your preferred terminal application and input the following command:

```console
<PathToDUNES>/DUNES$ ./bootstrap.sh
<PathToDUNES>/DUNES$ python3 ./bootstrap.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If bootstrap.py has an "execute" permission may be it would be better to remove python3 here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should probably leave it here for windows users? It doesn't hurt to have it, I don't think.

ScottBailey and others added 2 commits June 5, 2023 16:13
@mikelik
Copy link
Contributor

mikelik commented Jun 6, 2023

I run bootstrap.py successfully (it has created dunes:latest image) and after that when I'm starting the container:

mikel@msi:~/repo/DUNE$ docker start dunes_container
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "exit": executable file not found in $PATH: unknown
Error: failed to start containers: dunes_container

The same happens when I'm starting tests or running ./dunes --start my_node.
I'm running Ubuntu 20.

@mikelik
Copy link
Contributor

mikelik commented Jun 6, 2023

I run bootstrap.py successfully (it has created dunes:latest image) and after that when I'm starting the container:

mikel@msi:~/repo/DUNE$ docker start dunes_container
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "exit": executable file not found in $PATH: unknown
Error: failed to start containers: dunes_container

The same happens when I'm starting tests or running ./dunes --start my_node. I'm running Ubuntu 20.

I managed to fix this, so please disregard above comment. I think the reason was that I had some leftovers from tests in src/plugin (probably because I cancelled a running test and it didn't clean up).
Anyway after starting from scratch it works.

@mikelik
Copy link
Contributor

mikelik commented Jun 6, 2023

How does it work currently if I simply run pytest?
I see that by default test_bootstrap.py is executed if no flag is provided (this test is destructive). I thought it shouldn't be executed by default, should it?

@mikelik
Copy link
Contributor

mikelik commented Jun 6, 2023

How does it work currently if I simply run pytest? I see that by default test_bootstrap.py is executed if no flag is provided (this test is destructive). I thought it shouldn't be executed by default, should it?

This is fixed in 620ba5f

Copy link
Contributor

@mikelik mikelik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Scott!

@ScottBailey ScottBailey merged commit 2628a7f into main Jun 6, 2023
@ScottBailey ScottBailey deleted the sbailey/python_bootstrap branch June 6, 2023 14:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify win-*nix image bootstrapping method
4 participants