├── .circleci └── config.yml ├── .gitignore ├── .mailmap ├── AUTHORS ├── CONTRIBUTING.md ├── LICENSE ├── MAINTAINERS ├── Makefile ├── NOTICE ├── README.md ├── lcow.yml ├── pkg └── init-lcow │ ├── Dockerfile │ └── build.yml ├── poule.yml ├── scripts └── generate-authors.sh └── tests ├── RunTests.ps1 ├── cases ├── 000_basic │ ├── 001_info │ │ └── test.ps1 │ ├── 002_version │ │ └── test.ps1 │ ├── 003_ps │ │ └── test.ps1 │ ├── 010_hello_world │ │ └── test.ps1 │ ├── 015_pull_run_hello │ │ └── test.ps1 │ └── 030_busybox │ │ └── test.ps1 ├── 010_image │ ├── 010_pull │ │ ├── 010_multiarch │ │ │ └── test.ps1 │ │ ├── 020_with_dct │ │ │ └── test.ps1 │ │ ├── 021_with_dct_fail │ │ │ └── test.ps1 │ │ └── 030_pub-registry │ │ │ └── test.ps1 │ ├── 020_build │ │ ├── 010_simple │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 012_tag │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 014_iid │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 016_fail │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 020_build_arg │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 022_from_scratch_copy │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 023_from_scratch_add │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 024_from_build_arg │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 026_workdir │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 030_multistage │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 032_multistage_scratch │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ └── 100_copy │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ ├── 030_save │ │ └── test.ps1 │ ├── 040_load │ │ ├── hello-world.tar │ │ └── test.ps1 │ └── 050_inspect │ │ └── test.ps1 ├── 012_container │ ├── 030_run │ │ ├── 030_user │ │ │ └── test.ps1 │ │ ├── 035_env │ │ │ └── test.ps1 │ │ ├── 040_workdir │ │ │ └── test.ps1 │ │ ├── 042_workdir_dockerfile │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ ├── 050_read-only │ │ │ └── test.ps1 │ │ ├── 100_privileged │ │ │ └── test.ps1 │ │ ├── 150_shm-size │ │ │ └── test.ps1 │ │ └── 200_memory │ │ │ └── test.ps1 │ └── 040_inspect │ │ └── test.ps1 ├── 030_volume │ └── 010_local │ │ ├── 010_create_inspect_remove │ │ └── test.ps1 │ │ ├── 020_use │ │ └── test.ps1 │ │ ├── 030_reuse │ │ └── test.ps1 │ │ ├── 040_share │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 050_readonly │ │ └── test.ps1 │ │ └── 100_mkfifo │ │ └── test.ps1 ├── 100_hostvol │ ├── 010_touch │ │ └── test.ps1 │ ├── 012_readonly │ │ └── test.ps1 │ ├── 015_echo │ │ └── test.ps1 │ ├── 020_mkdir │ │ └── test.ps1 │ ├── 022_mkdir_host │ │ └── test.ps1 │ ├── 025_mkdir_p │ │ └── test.ps1 │ ├── 030_rmdir_host │ │ └── test.ps1 │ ├── 035_rmdir_nonempty │ │ ├── Dockerfile │ │ ├── rmdir_test.sh │ │ └── test.ps1 │ ├── 040_extended_ascii_name_volume │ │ └── test.ps1 │ ├── 042_extended_ascii_name_host │ │ └── test.ps1 │ ├── 044_unicode_name_volume │ │ └── test.ps1 │ ├── 046_unicode_name_host │ │ └── test.ps1 │ ├── 050_flock_volume │ │ ├── check_flock.sh │ │ └── test.ps1 │ ├── 052_flock_volume_containers │ │ ├── check_flock.sh │ │ └── test.ps1 │ ├── 060_symlink_volume │ │ ├── Dockerfile │ │ ├── symlink_test.sh │ │ └── test.ps1 │ ├── 065_hardlink_volume │ │ ├── Dockerfile │ │ ├── hardlink_test.sh │ │ └── test.ps1 │ ├── 070_socket_volume │ │ ├── Dockerfile │ │ ├── socket_test.sh │ │ └── test.ps1 │ ├── 075_mkfifo_volume │ │ ├── Dockerfile │ │ ├── mkfifo_test.sh │ │ └── test.ps1 │ ├── 090_mount_file │ │ └── test.ps1 │ ├── 095_mount_docker_socket │ │ ├── socket-test.sh │ │ └── test.ps1 │ ├── 100_chown_file_volume │ │ ├── Dockerfile │ │ ├── chown_test.sh │ │ └── test.ps1 │ ├── 105_chown_symlink_volume │ │ ├── Dockerfile │ │ ├── chown_test.sh │ │ └── test.ps1 │ ├── 110_chmod_file_mode_volume │ │ ├── Dockerfile │ │ ├── chmod_test.sh │ │ └── test.ps1 │ ├── 120_chmod_file_access_volume │ │ ├── Dockerfile │ │ ├── chmod_test.sh │ │ └── test.ps1 │ ├── 150_utime │ │ ├── check_time.sh │ │ └── test.ps1 │ └── 200_statfs │ │ ├── Dockerfile │ │ ├── statfs_test.sh │ │ └── test.ps1 ├── 110_hostnet │ └── 010_localhost │ │ └── test.ps1 ├── 200_compose │ └── 010_hello_world │ │ ├── docker-compose.yml │ │ └── test.ps1 ├── 300_apps │ └── placeholder ├── 900_perf │ ├── 010_image │ │ ├── 010_pull │ │ │ ├── 010_1_layer │ │ │ │ └── test.ps1 │ │ │ ├── 012_5_layers │ │ │ │ └── test.ps1 │ │ │ ├── 014_10_layers │ │ │ │ └── test.ps1 │ │ │ ├── 016_15_layers │ │ │ │ └── test.ps1 │ │ │ └── 018_20_layers │ │ │ │ └── test.ps1 │ │ └── 020_build │ │ │ ├── 012_5_layers │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ │ ├── 014_10_layers │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ │ ├── 016_15_layers │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ │ ├── 018_20_layers │ │ │ ├── Dockerfile │ │ │ └── test.ps1 │ │ │ └── group.ps1 │ └── 100_hostvol │ │ ├── 010_dd │ │ ├── 010_200MB_1KB_blocks │ │ │ └── test.ps1 │ │ ├── 012_200MB_4KB_blocks │ │ │ └── test.ps1 │ │ ├── 014_200MB_16KB_blocks │ │ │ └── test.ps1 │ │ ├── 016_200MB_64KB_blocks │ │ │ └── test.ps1 │ │ ├── 018_200MB_1MB_blocks │ │ │ └── test.ps1 │ │ └── 020_100MB_4KB_blocks_parallel │ │ │ ├── dd_5_parallel.sh │ │ │ └── test.ps1 │ │ └── 020_single_dir │ │ ├── 010_stat_5000_files │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 015_stat_5000_non_existing_files │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 020_touch_5000_files │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 030_touch_stat_5000_files │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 040_stat_touch_5000_files │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 050_stat_touch_stat_5000_files │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 060_write_5000_files_512B │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 065_write_write_5000_files_512B │ │ ├── run.sh │ │ └── test.ps1 │ │ ├── 070_stat_read_5000_files_512B │ │ ├── run.sh │ │ └── test.ps1 │ │ └── 075_stat_read_stat_read_5000_files_512B │ │ ├── run.sh │ │ └── test.ps1 ├── _lib │ └── lib.ps1 └── group.ps1 └── scripts ├── Dockerfile.10layers ├── Dockerfile.15layers ├── Dockerfile.1layer ├── Dockerfile.20layers ├── Dockerfile.5layers └── generate.sh /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | build: 4 | docker: 5 | - image: debian:stretch 6 | steps: 7 | - run: 8 | name: Install packages 9 | # ca-certificates are needed for attach_workspace (and git over https) 10 | command: apt-get update && apt-get install -y ca-certificates git openssh-client curl make zip 11 | - checkout 12 | - run: 13 | name: Configure $PATH 14 | command: echo 'export PATH=/work/bin:$PATH' >> $BASH_ENV 15 | - setup_remote_docker: 16 | version: 17.06.1-ce 17 | - run: 18 | name: Create directories 19 | command: mkdir -p /work/bin /work/out 20 | - run: 21 | name: Fetch binaries 22 | command: | 23 | curl -fsSL -o /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-17.06.2-ce.tgz 24 | curl -fsSL -o /work/bin/linuxkit https://521-46932243-gh.circle-artifacts.com/0/linuxkit-linux-amd64 25 | tar xfO /tmp/docker.tgz docker/docker > /work/bin/docker 26 | sha256sum /work/bin/* 27 | sha256sum -c < /work/out/SHA256SUM 42 | - store_artifacts: 43 | path: /work/out 44 | destination: . 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.efi 2 | *.img 3 | *.swp 4 | *.zip 5 | *-kernel 6 | *-cmdline 7 | *-state 8 | /kernel 9 | versions.txt 10 | /tests/_results 11 | /tests/bin 12 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Ian Campbell 2 | Ian Campbell 3 | Ian Campbell 4 | Justin Cormack 5 | Justin Cormack 6 | Rolf Neugebauer 7 | Rolf Neugebauer 8 | Rolf Neugebauer 9 | Sebastiaan van Stijn -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | # This file lists all individuals having contributed content to the repository. 2 | # For how it is generated, see `scripts/generate-authors.sh`. 3 | 4 | Ian Campbell 5 | Justin Cormack 6 | Rolf Neugebauer 7 | Sebastiaan van Stijn 8 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to LinuxKit 2 | 3 | Want to hack on this project? Awesome! Here are instructions to get you started. 4 | 5 | Additional information can be found in the docs: 6 | [issue triage](https://github.com/linuxkit/linuxkit/blob/master/docs/issue-triage.md), 7 | and [review process](https://github.com/linuxkit/linuxkit/blob/master/docs/reviewing.md). 8 | 9 | ## Reporting security issues 10 | 11 | The LinuxKit maintainers take security seriously. If you discover a security 12 | issue, please bring it to their attention right away! 13 | 14 | Please **DO NOT** file a public issue, instead send your report privately to 15 | [security@docker.com](mailto:security@docker.com). 16 | 17 | Security reports are greatly appreciated and we will publicly thank you for it. 18 | We also like to send gifts—if you're into Docker schwag, make sure to let 19 | us know. We currently do not offer a paid security bounty program, but are not 20 | ruling it out in the future. 21 | 22 | ## Reporting other issues 23 | 24 | A great way to contribute to the project is to send a detailed report when you 25 | encounter an issue. We always appreciate a well-written, thorough bug report, 26 | and will thank you for it! 27 | 28 | Check that [our issue database](https://github.com/linuxkit/linuxkit/issues) 29 | doesn't already include that problem or suggestion before submitting an issue. 30 | If you find a match, you can use the "subscribe" button to get notified on 31 | updates. Do *not* leave random "+1" or "I have this too" comments, as they 32 | only clutter the discussion, and don't help resolving it. However, if you 33 | have ways to reproduce the issue or have additional information that may help 34 | resolving the issue, please leave a comment. 35 | 36 | Also include the steps required to reproduce the problem if possible and 37 | applicable. This information will help us review and fix your issue faster. 38 | When sending lengthy log-files, consider posting them as a gist (https://gist.github.com). 39 | Don't forget to remove sensitive data from your logfiles before posting (you can 40 | replace those parts with "REDACTED"). 41 | 42 | ## Quick contribution tips and guidelines 43 | 44 | This section gives the experienced contributor some tips and guidelines. 45 | 46 | ### Pull requests are always welcome 47 | 48 | Not sure if that typo is worth a pull request? Found a bug and know how to fix 49 | it? Do it! We will appreciate it. Any significant improvement should be 50 | documented as [a GitHub issue](https://github.com/linuxkit/linuxkit/issues) before 51 | anybody starts working on it. 52 | 53 | We are always thrilled to receive pull requests. We do our best to process them 54 | quickly. If your pull request is not accepted on the first try, don't get 55 | discouraged! Our contributor's guide explains [the review process we 56 | use for simple changes](https://docs.docker.com/opensource/workflow/make-a-contribution/). 57 | 58 | ### Design and cleanup proposals 59 | 60 | You can propose new designs for existing features. You can also design 61 | entirely new features. We really appreciate contributors who want to refactor or 62 | otherwise cleanup our project. For information on making these types of 63 | contributions, see [the advanced contribution 64 | section](https://docs.docker.com/opensource/workflow/advanced-contributing/) in 65 | the contributors guide. 66 | 67 | We try hard to keep LinuxKit lean and focused. LinuxKit can't do everything for 68 | everybody. This means that we might decide against incorporating a new feature. 69 | However, there might be a way to implement that feature *on top of* LinuxKit. 70 | 71 | ### Commit Messages 72 | 73 | Commit messages must start with a capitalized and short summary (max. 50 chars) 74 | written in the imperative, followed by an optional, more detailed explanatory 75 | text which is separated from the summary by an empty line. 76 | 77 | Commit messages should follow best practices, including explaining the context 78 | of the problem and how it was solved, including in caveats or follow up changes 79 | required. They should tell the story of the change and provide readers 80 | understanding of what led to it. 81 | 82 | If you're lost about what this even means, please see [How to Write a Git 83 | Commit Message](http://chris.beams.io/posts/git-commit/) for a start. 84 | 85 | In practice, the best approach to maintaining a nice commit message is to 86 | leverage a `git add -p` and `git commit --amend` to formulate a solid 87 | changeset. This allows one to piece together a change, as information becomes 88 | available. 89 | 90 | If you squash a series of commits, don't just submit that. Re-write the commit 91 | message, as if the series of commits was a single stroke of brilliance. 92 | 93 | That said, there is no requirement to have a single commit for a PR, as long as 94 | each commit tells the story. For example, if there is a feature that requires a 95 | package, it might make sense to have the package in a separate commit then have 96 | a subsequent commit that uses it. 97 | 98 | Remember, you're telling part of the story with the commit message. Don't make 99 | your chapter weird. 100 | 101 | 102 | ### Review 103 | 104 | Code review comments may be added to your pull request. Discuss, then make the 105 | suggested modifications and push additional commits to your feature branch. Post 106 | a comment after pushing. New commits show up in the pull request automatically, 107 | but the reviewers are notified only when you comment. 108 | 109 | Pull requests must be cleanly rebased on top of master without multiple branches 110 | mixed into the PR. 111 | 112 | **Git tip**: If your PR no longer merges cleanly, use `rebase master` in your 113 | feature branch to update your pull request rather than `merge master`. 114 | 115 | Before you make a pull request, squash your commits into logical units of work 116 | using `git rebase -i` and `git push -f`. A logical unit of work is a consistent 117 | set of patches that should be reviewed together: for example, upgrading the 118 | version of a vendored dependency and taking advantage of its now available new 119 | feature constitute two separate units of work. Implementing a new function and 120 | calling it in another file constitute a single logical unit of work. The very 121 | high majority of submissions should have a single commit, so if in doubt: squash 122 | down to one. 123 | 124 | After every commit, [make sure the test suite passes] 125 | (https://docs.docker.com/opensource/project/test-and-docs/). Include documentation 126 | changes in the same pull request so that a revert would remove all traces of 127 | the feature or fix. 128 | 129 | Include an issue reference like `Closes #XXXX` or `Fixes #XXXX` in commits that 130 | close an issue. Including references automatically closes the issue on a merge. 131 | 132 | ### Merge approval 133 | 134 | Docker maintainers use LGTM (Looks Good To Me) in comments or GitHub approval 135 | on the code review to indicate acceptance. 136 | 137 | A change requires at least one LGTM from a maintainers of each component 138 | affected. A list of maintainers can be found in the [MAINTAINERS](MAINTAINERS) 139 | file. 140 | 141 | ### Community Guidelines and Code of Conduct 142 | 143 | When contributing to this project, we expect you to respect our community 144 | guidelines and [code of conduct](https://github.com/docker/code-of-conduct) 145 | 146 | We want to keep the community awesome, growing and collaborative. We need your 147 | help to keep it that way. To help with this we've come up with some general 148 | guidelines for the community as a whole: 149 | 150 | * Be nice: Be courteous, respectful and polite to fellow community members: 151 | no regional, racial, gender, or other abuse will be tolerated. We like 152 | nice people way better than mean ones! 153 | 154 | * Encourage diversity and participation: Make everyone in our community feel 155 | welcome, regardless of their background and the extent of their 156 | contributions, and do everything possible to encourage participation in 157 | our community. 158 | 159 | * Keep it legal: Basically, don't get us in trouble. Share only content that 160 | you own, do not share private or sensitive information, and don't break 161 | the law. 162 | 163 | * Stay on topic: Make sure that you are posting to the correct channel and 164 | avoid off-topic discussions. Remember when you update an issue or respond 165 | to an email you are potentially sending to a large number of people. Please 166 | consider this before you update. Also remember that nobody likes spam. 167 | 168 | * Don't send email to the maintainers: There's no need to send email to the 169 | maintainers to ask them to investigate an issue or to take a look at a 170 | pull request. Instead of sending an email, GitHub mentions should be 171 | used to ping maintainers to review a pull request, a proposal or an 172 | issue. 173 | 174 | ### Guideline violations — 3 strikes method 175 | 176 | The point of this section is not to find opportunities to punish people, but we 177 | do need a fair way to deal with people who are making our community suck. 178 | 179 | 1. First occurrence: We'll give you a friendly, but public reminder that the 180 | behavior is inappropriate according to our guidelines. 181 | 182 | 2. Second occurrence: We will send you a private message with a warning that 183 | any additional violations will result in removal from the community. 184 | 185 | 3. Third occurrence: Depending on the violation, we may need to delete or ban 186 | your account. 187 | 188 | **Notes:** 189 | 190 | * Obvious spammers are banned on first occurrence. If we don't do this, we'll 191 | have spam all over the place. 192 | 193 | * Violations are forgiven after 6 months of good behavior, and we won't hold a 194 | grudge. 195 | 196 | * People who commit minor infractions will get some education, rather than 197 | hammering them in the 3 strikes process. 198 | 199 | * The rules apply equally to everyone in the community, no matter how much 200 | you've contributed. 201 | 202 | * Extreme violations of a threatening, abusive, destructive or illegal nature 203 | will be addressed immediately and are not subject to 3 strikes or forgiveness. 204 | 205 | * Contact abuse@docker.com to report abuse or appeal violations. In the case of 206 | appeals, we know that mistakes happen, and we'll work with you to come up with a 207 | fair solution if there has been a misunderstanding. 208 | 209 | ### Sign your work 210 | 211 | The sign-off is a simple line at the end of the explanation for the patch. Your 212 | signature certifies that you wrote the patch or otherwise have the right to pass 213 | it on as an open-source patch. The rules are pretty simple: if you can certify 214 | the below (from [developercertificate.org](http://developercertificate.org/)): 215 | 216 | ``` 217 | Developer Certificate of Origin 218 | Version 1.1 219 | 220 | Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 221 | 1 Letterman Drive 222 | Suite D4700 223 | San Francisco, CA, 94129 224 | 225 | Everyone is permitted to copy and distribute verbatim copies of this 226 | license document, but changing it is not allowed. 227 | 228 | 229 | Developer's Certificate of Origin 1.1 230 | 231 | By making a contribution to this project, I certify that: 232 | 233 | (a) The contribution was created in whole or in part by me and I 234 | have the right to submit it under the open source license 235 | indicated in the file; or 236 | 237 | (b) The contribution is based upon previous work that, to the best 238 | of my knowledge, is covered under an appropriate open source 239 | license and I have the right under that license to submit that 240 | work with modifications, whether created in whole or in part 241 | by me, under the same open source license (unless I am 242 | permitted to submit under a different license), as indicated 243 | in the file; or 244 | 245 | (c) The contribution was provided directly to me by some other 246 | person who certified (a), (b) or (c) and I have not modified 247 | it. 248 | 249 | (d) I understand and agree that this project and the contribution 250 | are public and that a record of the contribution (including all 251 | personal information I submit with it, including my sign-off) is 252 | maintained indefinitely and may be redistributed consistent with 253 | this project or the open source license(s) involved. 254 | ``` 255 | 256 | Then you just add a line to every git commit message: 257 | 258 | Signed-off-by: Joe Smith 259 | 260 | Use your real name (sorry, no pseudonyms or anonymous contributions.) 261 | 262 | If you set your `user.name` and `user.email` git configs, you can sign your 263 | commit automatically with `git commit -s`. 264 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | https://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | Copyright 2015-2017 Docker, Inc. 180 | 181 | Licensed under the Apache License, Version 2.0 (the "License"); 182 | you may not use this file except in compliance with the License. 183 | You may obtain a copy of the License at 184 | 185 | https://www.apache.org/licenses/LICENSE-2.0 186 | 187 | Unless required by applicable law or agreed to in writing, software 188 | distributed under the License is distributed on an "AS IS" BASIS, 189 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 190 | See the License for the specific language governing permissions and 191 | limitations under the License. 192 | -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | # Project maintainers file 2 | # 3 | # This file describes who runs the linuxkit/linuxkit project and how. 4 | # This is a living document - if you see something out of date or missing, speak up! 5 | # 6 | # It is structured to be consumable by both humans and programs. 7 | # To extract its contents programmatically, use any TOML-compliant parser. 8 | # 9 | # This file is compiled into the MAINTAINERS file in docker/opensource. 10 | # 11 | [Org] 12 | [Org."Core maintainers"] 13 | people = [ 14 | "deitch", 15 | "ijc", 16 | "justincormack", 17 | "riyazdf", 18 | "rn", 19 | ] 20 | 21 | [people] 22 | 23 | # A reference list of all people associated with the project. 24 | # All other sections should refer to people by their canonical key 25 | # in the people section. 26 | 27 | # ADD YOURSELF HERE IN ALPHABETICAL ORDER 28 | [People.deitch] 29 | Name = "Avi Deitcher" 30 | Email = "avi@atomicinc.com" 31 | GitHub = "deitch" 32 | 33 | [People.ijc] 34 | Name = "Ian Campbell" 35 | Email = "ian.campbell@docker.com" 36 | GitHub = "ijc" 37 | 38 | [people.justincormack] 39 | Name = "Justin Cormack" 40 | Email = "justin.cormack@docker.com" 41 | GitHub = "justincormack" 42 | 43 | [people.riyazdf] 44 | Name = "Riyaz Faizullabhoy" 45 | Email = "riyaz@docker.com" 46 | GitHub = "riyazdf" 47 | 48 | [people.rn] 49 | Name = "Rolf Neugebauer" 50 | Email = "rolf.neugebauer@docker.com" 51 | GitHub = "rn" 52 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build 2 | build: lcow.yml Makefile 3 | linuxkit build lcow.yml 4 | mv lcow-kernel kernel 5 | mv lcow-initrd.img initrd.img 6 | kernel: build 7 | initrd.img: build 8 | 9 | .PHONY: release 10 | release: release.zip 11 | release.zip: kernel initrd.img versions.txt 12 | zip $@ kernel initrd.img versions.txt 13 | 14 | versions.txt: 15 | linuxkit version >> $@ 16 | git rev-list -1 HEAD >> $@ 17 | 18 | clean: 19 | rm -f lcow-initrd.img lcow-kernel lcow-cmdline versions.txt release.zip 20 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2015-2017 Docker, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | https://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LinuxKit based LCOW images 2 | 3 | [![CircleCI](https://circleci.com/gh/linuxkit/lcow.svg?style=svg)](https://circleci.com/gh/linuxkit/lcow) 4 | 5 | This repository hosts the components to build a LinuxKit based Linux 6 | image for Linux Containers on Windows. 7 | 8 | **Note:** LCOW support was **experimental** and is no longer being developed. This 9 | repository is now archived. 10 | 11 | 12 | ## Use 13 | 14 | This section describes how to use Linux Containers on Windows with LinuxKit. 15 | 16 | 17 | ### Prerequisites 18 | 19 | To use Linux Containers on Windows you need a Windows build supporting 20 | the feature, i.e., Windows 10 Pro or Windows Server 2016 1709 (or 21 | newer Insider builds). You also need to have `Hyper-V` and the 22 | `Container` feature enabled. 23 | 24 | 25 | ### Setup 26 | 27 | For now, you need a recent version of `docker`, such as a nightly 28 | build from the master branch. In PowerShell: 29 | 30 | ``` 31 | Invoke-WebRequest -UseBasicParsing -OutFile docker.zip https://master.dockerproject.com/windows/x86_64/docker.zip 32 | Expand-Archive docker.zip -DestinationPath $Env:ProgramFiles 33 | ``` 34 | 35 | Next, you need to get the LinuxKit images. You can either build them 36 | yourself (see below) or download the latest zip file from the 37 | [releases page](https://github.com/linuxkit/lcow/releases). Then unzip 38 | in an elevated PowerShell: 39 | 40 | ``` 41 | Remove-Item "$env:ProgramFiles\Linux Containers" -Force -Recurse 42 | Expand-Archive release.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\." 43 | rm release.zip 44 | ``` 45 | 46 | ### Run 47 | 48 | On recent `docker` master builds (`master-dockerproject-2018-01-20, build 44a1168a` or newer): 49 | 50 | Start the docker daemon (in an elevated PowerShell): 51 | 52 | ``` 53 | .\dockerd.exe -D --experimental 54 | ``` 55 | 56 | You should now be able to run Linux containers on Windows, e.g.: 57 | 58 | ``` 59 | docker run --platform linux --rm -ti busybox sh 60 | ``` 61 | 62 | On older `docker` master builds: 63 | 64 | Start the docker daemon (in an elevated PowerShell): 65 | 66 | ``` 67 | $env:LCOW_SUPPORTED=1 68 | $env:LCOW_API_PLATFORM_IF_OMITTED="linux" 69 | Remove-Item c:\lcow -Force -Recurse; mkdir c:\lcow 70 | .\dockerd.exe -D --experimental --data-root c:\lcow 71 | ``` 72 | 73 | (Note: If your kernel is older than 4.14 and is configured with KASLR 74 | you may want to add `--storage-opt lcow.bootparameters="nokaslr"` to 75 | the `dockerd` command line.) 76 | 77 | You should now be able to run Linux containers on Windows, e.g.: 78 | 79 | ``` 80 | docker run --rm -ti busybox sh 81 | ``` 82 | 83 | If you already have `docker` installed on your system you probably 84 | want to start the daemon (and the client) on a non-standard named pipe 85 | using the `-H "npipe:////./pipe//docker_lcow"` for both. 86 | 87 | 88 | ## Build 89 | 90 | The LinuxKit image is build from [`lcow.yml`](./lcow.yml) and the main 91 | package is called [`init-lcow`](./pkg/init-lcow). 92 | 93 | ### Prerequisites 94 | 95 | To build images and packages you will need the [LinuxKit 96 | tool](https://github.com/linuxkit/linuxkit/tree/master/src/cmd/linuxkit). You 97 | also need to have a working Docker installation. 98 | 99 | If you already have `go` installed you can use `go get -u 100 | github.com/linuxkit/linuxkit/src/cmd/linuxkit` to install the 101 | `linuxkit` tool. 102 | 103 | On macOS there is a `brew tap` available. Detailed instructions are at 104 | [linuxkit/homebrew-linuxkit](https://github.com/linuxkit/homebrew-linuxkit), 105 | but the short summary is: 106 | 107 | ``` 108 | brew tap linuxkit/linuxkit 109 | brew install --HEAD linuxkit 110 | ``` 111 | 112 | 113 | ### Building the LCOW image 114 | 115 | Simply type: 116 | 117 | ``` 118 | make 119 | ``` 120 | 121 | which generates `kernel` and `initrd.img` which need to be copied to `"$env:ProgramFiles\Linux Containers\kernel"` on your Windows system. 122 | 123 | 124 | Alternatively, use: 125 | 126 | ``` 127 | linuxkit build lcow.yml 128 | ``` 129 | 130 | This will generate three files: `lcow-kernel`, `lcow-initrd.img`, and 131 | `lcow-cmdline`. `lcow-kernel` needs to be copied to 132 | `"$env:ProgramFiles\Linux Containers\kernel"` and 133 | `lcow-initrd.img` to `"$env:ProgramFiles\Linux 134 | Containers\initrd.img"`. 135 | 136 | 137 | ### Building the `init-lcow` package 138 | 139 | The [`init-lcow`](./pkg/init-lcow) contains a minimal `init` system 140 | used inside the LCOW and mainly consists of the [OpenGCS 141 | deamon](https://github.com/Microsoft/opengcs). To rebuild the package 142 | use the `linuxkit` tool: 143 | 144 | ``` 145 | linuxkit pkg build -org foo pkg/init-lcow 146 | ``` 147 | 148 | This should create a local image `foo/init-lcow:` which can be used `lcow.yml`. To build and push the image to hub use: 149 | 150 | ``` 151 | linuxkit pkg build -org -disable-content-trust pkg/init-lcow 152 | ``` 153 | 154 | You can omit `-disable-content-trust` if your registry has Docker 155 | Content Trust enabled. 156 | 157 | 158 | ## Test 159 | 160 | The [`tests`](./tests) directory contains a number of tests for LCOW 161 | written using [`rtf`](https://github.com/linuxkit/rtf). To run them 162 | you can simply execute [`RunTests.ps1`](./tests/RunTests.ps1) inside 163 | the `.\tests` directory. It will pick up the kernel/initrd in the 164 | parent directory if present. Alternatively, it can download the 165 | artefact from CircleCI if you supply the build number. The script will 166 | also download the latest version of `docker` and the version of the 167 | `rtf` binary. 168 | 169 | Test results will be stored in `.\tests\_results\` directory 170 | where `` is the UUID printed out during the test run. 171 | 172 | To manually run the test, make sure you have a working LCOW system set 173 | up. You'll also need a copy of the `rtf.exe` binary (see 174 | [`RunTests.ps1`](./tests/RunTests.ps1) on how to obtain it or `go get 175 | ..` it). Further, `docker` must also be in your path. 176 | 177 | To run tests, use `rtf run` inside the `.\tests` directory. To list 178 | which tests are available use `rtf list` or `rtf info`. To run an 179 | individual test or a group of tests use `rtf run `. 180 | 181 | -------------------------------------------------------------------------------- /lcow.yml: -------------------------------------------------------------------------------- 1 | kernel: 2 | # For now use an older kernel. See https://github.com/linuxkit/linuxkit/issues/3120 3 | image: linuxkit/kernel:4.19.34 4 | cmdline: "console=ttyS0" 5 | tar: none 6 | init: 7 | - linuxkit/init-lcow:e622118d49da5e1bea01e7cdf414c491d8b7c015 8 | - linuxkit/runc:v0.7 9 | files: 10 | - path: etc/linuxkit.yml 11 | metadata: yaml 12 | trust: 13 | org: 14 | - linuxkit 15 | -------------------------------------------------------------------------------- /pkg/init-lcow/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM linuxkit/alpine:86cd4f51b49fb9a078b50201d892a3c7973d48ec AS mirror 2 | RUN mkdir -p /out/etc/apk && cp -r /etc/apk/* /out/etc/apk/ 3 | RUN apk add --no-cache --initdb -p /out \ 4 | alpine-baselayout \ 5 | busybox \ 6 | e2fsprogs \ 7 | musl 8 | RUN rm -rf /out/etc/apk /out/lib/apk /out/var/cache 9 | 10 | FROM linuxkit/alpine:86cd4f51b49fb9a078b50201d892a3c7973d48ec AS build 11 | ENV OPENGCS_REPO=https://github.com/Microsoft/opengcs 12 | ENV OPENGCS_COMMIT=fefd0ad73f6bfa33b8cce597be303e134fddc408 13 | RUN apk add --no-cache build-base curl git go linux-headers musl-dev 14 | ENV GOPATH=/go PATH=$PATH:/go/bin 15 | RUN git clone $OPENGCS_REPO /go/src/github.com/Microsoft/opengcs && \ 16 | cd /go/src/github.com/Microsoft/opengcs && \ 17 | git checkout $OPENGCS_COMMIT && \ 18 | make bin/init bin/vsockexec bin/gcs bin/gcstools && \ 19 | cd bin && \ 20 | for tool in vhd2tar exportSandbox netnscfg remotefs; do ln -s gcstools $tool; done 21 | 22 | RUN mkdir -p /out/bin && \ 23 | mkdir -p /out/sbin && \ 24 | cp -r /go/src/github.com/Microsoft/opengcs/bin/* /out/bin && \ 25 | mv /out/bin/init /out && \ 26 | curl -fSL "https://raw.githubusercontent.com/mirror/busybox/38d966943f5288bb1f2e7219f50a92753c730b14/examples/udhcp/simple.script" -o /out/sbin/udhcpc_config.script && \ 27 | chmod ugo+rx /out/sbin/udhcpc_config.script && \ 28 | git -C /go/src/github.com/Microsoft/opengcs rev-parse HEAD > /out/gcs.commit && \ 29 | git -C /go/src/github.com/Microsoft/opengcs rev-parse --abbrev-ref HEAD > /out/gcs.branch 30 | 31 | FROM scratch 32 | ENTRYPOINT [] 33 | CMD [] 34 | WORKDIR / 35 | COPY --from=mirror /out/ / 36 | COPY --from=build /out/ / 37 | -------------------------------------------------------------------------------- /pkg/init-lcow/build.yml: -------------------------------------------------------------------------------- 1 | image: init-lcow 2 | network: true 3 | arches: 4 | - amd64 5 | -------------------------------------------------------------------------------- /poule.yml: -------------------------------------------------------------------------------- 1 | # Add a "status/0-triage" to every newly opened pull request. 2 | - triggers: 3 | pull_request: [ opened ] 4 | operations: 5 | - type: label 6 | filters: { 7 | ~labels: [ "status/0-triage", "status/1-design-review", "status/2-code-review", "status/3-docs-review", "status/4-merge" ], 8 | } 9 | settings: { 10 | patterns: { 11 | status/0-triage: [ ".*" ], 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /scripts/generate-authors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")/.." 5 | 6 | # see also ".mailmap" for how email addresses and names are deduplicated 7 | 8 | { 9 | cat <<-'EOH' 10 | # This file lists all individuals having contributed content to the repository. 11 | # For how it is generated, see `scripts/generate-authors.sh`. 12 | EOH 13 | echo 14 | git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf 15 | } > AUTHORS 16 | -------------------------------------------------------------------------------- /tests/RunTests.ps1: -------------------------------------------------------------------------------- 1 | # Script to tests. 2 | 3 | # Handle kernel/initrd 4 | # If no buildnumber is supplied then it uses the locally build kernel+initrd 5 | if ( Test-Path "$env:ProgramFiles\Linux Containers") { 6 | Remove-Item "$env:ProgramFiles\Linux Containers" -Force -Recurse 7 | } 8 | if ( $args.Count -eq 1 ) { 9 | $BuildNumber = $args[0] 10 | Write-Output "Downloading artefacts for build $BuildNumber" 11 | Invoke-WebRequest -UseBasicParsing -OutFile release.zip "https://$BuildNumber-111085629-gh.circle-artifacts.com/0/release.zip" 12 | Expand-Archive release.zip -DestinationPath "$Env:ProgramFiles\Linux Containers\." 13 | Remove-Item release.zip 14 | } else { 15 | if ( !(Test-Path ..\lcow-kernel) -and !(Test-Path ..\kernel) ) { 16 | Write-Output "Could not find kernel" 17 | exit 1 18 | } 19 | if ( !(Test-Path ..\lcow-initrd.img) -and !(Test-Path ..\initrd.img) ) { 20 | Write-Output "Could not find initial ram disk image" 21 | exit 1 22 | } 23 | mkdir "$env:ProgramFiles\Linux Containers" 24 | if ( Test-Path ..\lcow-kernel ) { 25 | Copy-Item ..\lcow-kernel "$env:ProgramFiles\Linux Containers\kernel" 26 | } else { 27 | Copy-Item ..\kernel "$env:ProgramFiles\Linux Containers\kernel" 28 | } 29 | if ( Test-Path ..\lcow-initrd.img ) { 30 | Copy-Item ..\lcow-initrd.img "$env:ProgramFiles\Linux Containers\initrd.img" 31 | } else { 32 | Copy-Item ..\initrd.img "$env:ProgramFiles\Linux Containers\initrd.img" 33 | } 34 | } 35 | 36 | if ( !(Test-Path .\bin) ) { 37 | New-Item -itemtype directory .\bin 38 | } 39 | 40 | if ( !(Test-Path .\bin\dockerd.exe) ) { 41 | Write-Output "Downloading latest docker" 42 | Invoke-WebRequest -UseBasicParsing -OutFile bin\dockerd.exe https://master.dockerproject.org/windows/x86_64/dockerd.exe 43 | Invoke-WebRequest -UseBasicParsing -OutFile bin\docker.exe https://master.dockerproject.org/windows/x86_64/docker.exe 44 | } 45 | 46 | $composeRelease = "1.21.0-rc1" 47 | if ( !(Test-Path .\bin\docker-compose.exe) ) { 48 | Write-Output "Downloading latest docker-compose" 49 | # Force to TLS 1.2 50 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 51 | Invoke-WebRequest -UseBasicParsing -OutFile bin\docker-compose.exe "https://github.com/docker/compose/releases/download/$composeRelease/docker-compose-Windows-x86_64.exe" 52 | } 53 | 54 | $rtfBuildNumber = 69 55 | if ( !(Test-Path .\bin\rtf.exe) ) { 56 | Invoke-WebRequest -UseBasicParsing -OutFile bin\rtf.exe "https://$rtfBuildNumber-89472225-gh.circle-artifacts.com/0/rtf-windows-amd64.exe" 57 | } 58 | 59 | $p = [string]$pwd.Path 60 | $env:PATH="$env:PATH;$p\bin" 61 | 62 | # Start the docker daemon in the background. Use a separate data-root to have a clean slate 63 | if ( Test-Path C:\lcow-test ) { 64 | Remove-Item C:\lcow-test -Force -Recurse 65 | } 66 | Start-Process dockerd.exe -ArgumentList '-D', '--experimental', '--data-root', 'C:\lcow-test' ` 67 | -NoNewWindow -RedirectStandardOutput '.\bin\dockerd.out' -RedirectStandardError '.\bin\dockerd.err' 68 | 69 | Start-Sleep -Seconds 5 70 | 71 | rtf.exe run 72 | 73 | Stop-Process -Name dockerd 74 | -------------------------------------------------------------------------------- /tests/cases/000_basic/001_info/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run docker info 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker info 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | 16 | exit 0 17 | -------------------------------------------------------------------------------- /tests/cases/000_basic/002_version/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run docker version 2 | # LABELS: 3 | # REPEAT: 4 | 5 | docker version 6 | if ($lastexitcode -ne 0) { exit 1 } 7 | exit 0 -------------------------------------------------------------------------------- /tests/cases/000_basic/003_ps/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run docker ps 2 | # LABELS: 3 | # REPEAT: 4 | 5 | docker ps 6 | if ($lastexitcode -ne 0) { exit 1 } 7 | exit 0 -------------------------------------------------------------------------------- /tests/cases/000_basic/010_hello_world/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run docker container run hello-world 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker container run --platform linux --rm hello-world 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | 16 | # Check that we use lcow 17 | $tmp = $output | select-string "Hello from Docker!" -SimpleMatch 18 | if ($tmp.length -eq 0) { 19 | exit 1 20 | } 21 | 22 | docker image rm --force hello-world 23 | if ($lastexitcode -ne 0) { 24 | exit 1 25 | } 26 | 27 | exit 0 28 | -------------------------------------------------------------------------------- /tests/cases/000_basic/015_pull_run_hello/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Pull hello-world and run it 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | docker image rm hello-world 10 | 11 | docker image pull --platform linux hello-world 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | # If we pulled with --platform we should not need to specify it for run 17 | $output = [string] (& docker container run --rm hello-world 2>&1) 18 | if ($lastexitcode -ne 0) { 19 | $output 20 | exit 1 21 | } 22 | $output 23 | 24 | $tmp = $output | select-string "Hello from Docker!" -SimpleMatch 25 | if ($tmp.length -eq 0) { 26 | exit 1 27 | } 28 | 29 | docker image rm --force hello-world 30 | if ($lastexitcode -ne 0) { 31 | exit 1 32 | } 33 | 34 | exit 0 35 | -------------------------------------------------------------------------------- /tests/cases/000_basic/030_busybox/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run uname -a in busybox 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker container run --platform linux --rm busybox uname -a 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | 16 | # Check that we use lcow 17 | $tmp = $output | select-string "Linux" -SimpleMatch 18 | if ($tmp.length -eq 0) { 19 | exit 1 20 | } 21 | exit 0 22 | -------------------------------------------------------------------------------- /tests/cases/010_image/010_pull/010_multiarch/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run docker image pull with a multiarch manifest list 2 | # LABELS: 3 | # REPEAT: 4 | 5 | docker image pull --platform linux alpine:3.7 6 | if ($lastexitcode -ne 0) { exit 1 } 7 | exit 0 8 | -------------------------------------------------------------------------------- /tests/cases/010_image/010_pull/020_with_dct/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run docker image pull with content trust 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $env:DOCKER_CONTENT_TRUST=1 6 | docker image pull --platform linux alpine:3.7 7 | if ($lastexitcode -ne 0) { exit 1 } 8 | exit 0 9 | -------------------------------------------------------------------------------- /tests/cases/010_image/010_pull/021_with_dct_fail/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run docker image pull unsigned image with content trust 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $env:DOCKER_CONTENT_TRUST=1 6 | docker image pull --platform linux prom/node-exporter 7 | if ($lastexitcode -eq 0) { exit 1 } 8 | exit 0 9 | -------------------------------------------------------------------------------- /tests/cases/010_image/010_pull/030_pub-registry/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Pull an image from a different public registry (gcr.io) 2 | # LABELS: 3 | # REPEAT: 4 | 5 | docker image pull --platform linux gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7 6 | if ($lastexitcode -ne 0) { exit 1 } 7 | exit 0 8 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/010_simple/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | RUN touch /simple 3 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/010_simple/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Simple docker image build test 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | 11 | docker image build --platform linux -t $imageName . 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | docker inspect $imageName 17 | if ($lastexitcode -ne 0) { 18 | exit 1 19 | } 20 | 21 | docker image rm $imageName 22 | if ($lastexitcode -ne 0) { 23 | exit 1 24 | } 25 | exit 0 26 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/012_tag/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | RUN touch /tag 3 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/012_tag/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Simple docker image build test with tagging 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | $imageTagged = $env:RT_TEST_NAME + ":foobar" 11 | 12 | docker image build --platform linux -t $imageName . 13 | if ($lastexitcode -ne 0) { 14 | exit 1 15 | } 16 | 17 | docker image tag $imageName $imageTagged 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | docker inspect $imageTagged 23 | if ($lastexitcode -ne 0) { 24 | exit 1 25 | } 26 | 27 | docker image rm $imageTagged 28 | if ($lastexitcode -ne 0) { 29 | exit 1 30 | } 31 | exit 0 32 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/014_iid/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | RUN touch /iid 3 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/014_iid/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Simple docker image build test with iid file 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $imageIIDFile = Join-Path -Path $env:TEST_TMP -ChildPath iid.file 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker image build --platform linux -t $imageName --iidfile $imageIIDFile . 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | if (!(Test-Path -Path $imageIIDFile)) { 23 | exit 1 24 | } 25 | 26 | $iid = Get-Content $imageIIDFile -Raw 27 | 28 | docker inspect $iid 29 | if ($lastexitcode -ne 0) { 30 | $ret = 1 31 | } 32 | 33 | docker image rm --force $iid 34 | if ($lastexitcode -ne 0) { 35 | $ret = 1 36 | } 37 | 38 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 39 | exit $ret 40 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/016_fail/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | RUN exit 1 3 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/016_fail/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check that build failures are propagated 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | 11 | docker image build --platform linux -t $imageName . 12 | if ($lastexitcode -eq 0) { 13 | exit 1 14 | } 15 | exit 0 16 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/020_build_arg/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | ARG ARGUMENT 3 | RUN echo ${ARGUMENT} 4 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/020_build_arg/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: docker image build with build arg 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/Microsoft/opengcs/issues/168 (closed) 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | 14 | $output = [string] (& docker image build --platform linux -t $imageName --build-arg ARGUMENT=foobar . 2>&1) 15 | if ($lastexitcode -ne 0) { 16 | $output 17 | exit 1 18 | } 19 | $output 20 | 21 | # Check that it echoed the right thing 22 | $tmp = $output | select-string "foobar" -SimpleMatch 23 | if ($tmp.length -eq 0) { 24 | $ret = 1 25 | } 26 | 27 | docker inspect $imageName 28 | if ($lastexitcode -ne 0) { 29 | $ret = 1 30 | } 31 | 32 | docker image rm $imageName 33 | if ($lastexitcode -ne 0) { 34 | $ret = 1 35 | } 36 | exit $ret 37 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/022_from_scratch_copy/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | COPY /Dockerfile . 3 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/022_from_scratch_copy/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: docker image build with FROM scratch and COPY a file 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/Microsoft/opengcs/issues/156 (closed) 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | 14 | docker image build --platform linux -t $imageName . 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | docker inspect $imageName 20 | if ($lastexitcode -ne 0) { 21 | $ret = 1 22 | } 23 | 24 | docker image rm $imageName 25 | if ($lastexitcode -ne 0) { 26 | $ret = 1 27 | } 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/023_from_scratch_add/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | ADD https://github.com/linuxkit/lcow/blob/master/lcow.yml /lcow.yml 3 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/023_from_scratch_add/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: docker image build with FROM scratch and use ADD to add a file 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/Microsoft/opengcs/issues/156 (closed) 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | 14 | docker image build --platform linux -t $imageName . 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | docker inspect $imageName 20 | if ($lastexitcode -ne 0) { 21 | $ret = 1 22 | } 23 | 24 | docker image rm $imageName 25 | if ($lastexitcode -ne 0) { 26 | $ret = 1 27 | } 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/024_from_build_arg/Dockerfile: -------------------------------------------------------------------------------- 1 | ARG IMAGE 2 | FROM ${IMAGE} 3 | RUN touch /${IMAGE} 4 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/024_from_build_arg/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: docker image build with FROM defined by build arg 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/Microsoft/opengcs/issues/168 (closed) 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | 14 | docker image build --platform linux -t $imageName --build-arg IMAGE=alpine:3.7 . 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | docker inspect $imageName 20 | if ($lastexitcode -ne 0) { 21 | $ret = 1 22 | } 23 | 24 | docker image rm $imageName 25 | if ($lastexitcode -ne 0) { 26 | $ret = 1 27 | } 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/026_workdir/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | WORKDIR /foo 3 | RUN touch workdir 4 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/026_workdir/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: docker image build with a WORKDIR set 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/docker/for-win/issues/1358 (closed) 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | 14 | docker image build --platform linux -t $imageName . 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | docker inspect $imageName 20 | if ($lastexitcode -ne 0) { 21 | $ret = 1 22 | } 23 | 24 | docker image rm $imageName 25 | if ($lastexitcode -ne 0) { 26 | $ret = 1 27 | } 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/030_multistage/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 AS stage0 2 | RUN touch /multi0 3 | 4 | FROM alpine:3.7 AS stage1 5 | RUN touch /multi1 6 | 7 | FROM alpine:3.7 8 | COPY --from=stage0 /multi0 / 9 | COPY --from=stage1 /multi1 / 10 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/030_multistage/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Multistage build 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/Microsoft/opengcs/issues/169 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | 14 | docker image build --platform linux -t $imageName . 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | docker inspect $imageName 20 | if ($lastexitcode -ne 0) { 21 | $ret = 1 22 | } 23 | 24 | docker image rm $imageName 25 | if ($lastexitcode -ne 0) { 26 | $ret = 1 27 | } 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/032_multistage_scratch/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 AS stage0 2 | RUN touch /multi-scratch0 3 | 4 | FROM alpine:3.7 AS stage1 5 | RUN touch /multi-scratch1 6 | 7 | FROM scratch 8 | COPY --from=stage0 /multi-scratch0 / 9 | COPY --from=stage1 /multi-scratch1 / 10 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/032_multistage_scratch/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Multistage build with a FROM scratch 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/Microsoft/opengcs/issues/169 5 | # ISSUE: https://github.com/moby/moby/issues/36115 6 | # ISSUE: https://github.com/moby/moby/issues/35413 (closed) 7 | # ISSUE: https://github.com/Microsoft/opengcs/issues/156 (closed) 8 | 9 | 10 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 11 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 12 | . $lib 13 | 14 | $ret = 0 15 | 16 | $imageName = $env:RT_TEST_NAME 17 | 18 | docker image build --platform linux -t $imageName . 19 | if ($lastexitcode -ne 0) { 20 | exit 1 21 | } 22 | 23 | docker inspect $imageName 24 | if ($lastexitcode -ne 0) { 25 | $ret = 1 26 | } 27 | 28 | docker image rm $imageName 29 | if ($lastexitcode -ne 0) { 30 | $ret = 1 31 | } 32 | exit $ret 33 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/100_copy/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | 3 | # Copy a file 4 | COPY /Dockerfile . 5 | COPY /test.ps1 / 6 | 7 | # Copy a file to non-existing destination and directory 8 | COPY /Dockerfile /bar/Dockerfile 9 | COPY /Dockerfile /foo/bar/baz/ 10 | COPY Dockerfile test.ps1 /baz/ 11 | 12 | # Copy a directory to root or another directory 13 | COPY folder1 / 14 | COPY folder1 /dest1 15 | 16 | # Copy a nested directory 17 | COPY folder2 / 18 | COPY folder2 /dest2/ 19 | 20 | # Relative to WORKDIR 21 | WORKDIR /work 22 | COPY Dockerfile . 23 | 24 | # verify. These are separate RUN commands to make it easier to debug 25 | RUN test -f /Dockerfile 26 | RUN test -f /test.ps1 27 | 28 | RUN test -f /bar/Dockerfile 29 | RUN test -f /foo/bar/baz/Dockerfile 30 | RUN test -f /baz/Dockerfile && test -f /baz/test.ps1 31 | 32 | RUN test -f /Dockerfile 33 | RUN test -f /dest1/Dockerfile 34 | 35 | RUN test -f /folder3/test.ps1 && test -f /folder3/Dockerfile 36 | RUN test -f /dest2/folder3/test.ps1 && test -f /dest2/folder3/Dockerfile 37 | 38 | RUN test -f /work/Dockerfile 39 | -------------------------------------------------------------------------------- /tests/cases/010_image/020_build/100_copy/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Test COPY variations 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/moby/moby/issues/36353 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | $testDir1 = "folder1" 14 | $testDir2 = "folder2" 15 | $testDir3 = "folder3" 16 | 17 | Remove-Item -Path $testDir1 -Force -Recurse -ErrorAction Ignore 18 | Remove-Item -Path $testDir2 -Force -Recurse -ErrorAction Ignore 19 | New-Item -ItemType Directory -Force -Path $testDir1 20 | New-Item -ItemType Directory -Force -Path $testDir2\$testDir3 21 | Copy-Item Dockerfile $testDir1 22 | Copy-Item test.ps1 $testDir2\$testDir3\ 23 | Copy-Item Dockerfile $testDir2\$testDir3\ 24 | # After this we should have 25 | # - Dockerfile 26 | # - test.ps1 27 | # - folder1 28 | # - Dockerfile 29 | # - folder2 30 | # - folder3 31 | # - test.ps1 32 | # - Dockerfile 33 | 34 | docker image build --platform linux -t $imageName . 35 | if ($lastexitcode -ne 0) { 36 | $ret = 1 37 | } 38 | docker image rm $imageName 39 | if ($lastexitcode -ne 0) { 40 | $ret = 1 41 | } 42 | 43 | Remove-Item -Path $testDir1 -Force -Recurse -ErrorAction Ignore 44 | Remove-Item -Path $testDir2 -Force -Recurse -ErrorAction Ignore 45 | exit $ret 46 | -------------------------------------------------------------------------------- /tests/cases/010_image/030_save/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Test docker image save 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "hello-world.tar" 12 | 13 | docker image pull --platform linux hello-world 14 | if ($lastexitcode -ne 0) { 15 | exit 1 16 | } 17 | 18 | docker image save -o $fileName hello-world 19 | if ($lastexitcode -ne 0) { 20 | $ret = 1 21 | } 22 | 23 | if (!(Test-Path $fileName)) { 24 | $ret = 1 25 | } 26 | Remove-Item -Path $fileName -Force -Recurse -ErrorAction Ignore 27 | exit $ret 28 | -------------------------------------------------------------------------------- /tests/cases/010_image/040_load/hello-world.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linuxkit/lcow/f926f46d1c5952024c251560a12fc50086cf1b62/tests/cases/010_image/040_load/hello-world.tar -------------------------------------------------------------------------------- /tests/cases/010_image/040_load/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Test docker image save 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $fileName = "hello-world.tar" 10 | $imageName = "hello-world" 11 | 12 | docker image rm hello-world 13 | 14 | docker image load -i $fileName 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | $output = [string] (& docker image inspect $imageName 2>&1) 20 | if ($lastexitcode -ne 0) { 21 | $output 22 | exit 1 23 | } 24 | Write-Output "Output of docker inspect of the image:" 25 | $output | ConvertFrom-Json | ConvertTo-Json 26 | 27 | # Now try to run it 28 | docker container run --rm $imageName 29 | if ($lastexitcode -ne 0) { 30 | exit 1 31 | } 32 | 33 | exit 0 34 | -------------------------------------------------------------------------------- /tests/cases/010_image/050_inspect/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check that docker image inspect works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = "hello-world" 10 | 11 | docker image pull --platform linux $imageName 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | $output = [string] (& docker inspect $imageName 2>&1) 17 | if ($lastexitcode -ne 0) { 18 | $output 19 | exit 1 20 | } 21 | Write-Output "Output of docker inspect of the image:" 22 | $output | ConvertFrom-Json | ConvertTo-Json 23 | 24 | exit 0 25 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/030_user/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that docker container run --user works 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/moby/moby/issues/36469 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $output = [string] (& docker container run --platform linux --rm --user postgres alpine:3.7 id 2>&1) 11 | if ($lastexitcode -ne 0) { 12 | $output 13 | exit 1 14 | } 15 | $output 16 | 17 | $tmp = $output | select-string "(postgres)" -SimpleMatch 18 | if ($tmp.length -eq 0) { 19 | exit 1 20 | } 21 | exit 0 22 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/035_env/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that docker container run --env works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker container run --platform linux --rm --env FOOBAR=foobar alpine:3.7 env 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | 16 | $tmp = $output | select-string "FOOBAR=foobar" -SimpleMatch 17 | if ($tmp.length -eq 0) { 18 | exit 1 19 | } 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/040_workdir/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that docker container run --workdir works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker container run --platform linux --rm --workdir /foobar alpine:3.7 pwd 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | 16 | $tmp = $output | select-string "/foobar" -SimpleMatch 17 | if ($tmp.length -eq 0) { 18 | exit 1 19 | } 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/042_workdir_dockerfile/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | WORKDIR /foobar 3 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/042_workdir_dockerfile/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that WORKDIR in a Dockerfile works 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/Microsoft/opengcs/issues/188 5 | # ISSUE: https://github.com/moby/moby/issues/36138 6 | 7 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 8 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 9 | . $lib 10 | 11 | $ret = 0 12 | 13 | $imageName = $env:RT_TEST_NAME 14 | docker image build --platform linux -t $imageName . 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | $output = [string] (& docker container run --platform linux --rm $imageName pwd 2>&1) 20 | if ($lastexitcode -ne 0) { 21 | $output 22 | $ret = 1 23 | } 24 | $output 25 | 26 | $tmp = $output | select-string "/foobar" -SimpleMatch 27 | if ($tmp.length -eq 0) { 28 | $ret = 1 29 | } 30 | 31 | docker image rm $imageName 32 | if ($lastexitcode -ne 0) { 33 | $ret = 1 34 | } 35 | 36 | exit $ret 37 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/050_read-only/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify docker container run --read-only works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | docker container run --platform linux --rm --read-only alpine:3.7 touch /foobar 10 | if ($lastexitcode -eq 0) { 11 | exit 1 12 | } 13 | exit 0 14 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/100_privileged/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that docker container run --privileged works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker container run --platform linux --rm --privileged alpine:3.7 id 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | exit 0 16 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/150_shm-size/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that docker container run --shm-size works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker container run --platform linux --rm --shm-size 4096 alpine:3.7 sh -c "mount | grep shm" 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | 16 | if (!($output -match "size=4k")) { 17 | exit 1 18 | } 19 | exit 0 20 | -------------------------------------------------------------------------------- /tests/cases/012_container/030_run/200_memory/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that docker container run --memory works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $output = [string] (& docker container run --platform linux --rm --memory 104857600 alpine:3.7 cat /sys/fs/cgroup/memory/memory.limit_in_bytes 2>&1) 10 | if ($lastexitcode -ne 0) { 11 | $output 12 | exit 1 13 | } 14 | $output 15 | 16 | if (!($output -match "104857600")) { 17 | exit 1 18 | } 19 | exit 0 20 | -------------------------------------------------------------------------------- /tests/cases/012_container/040_inspect/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check that docker container inspect works 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = "hello-world" 10 | $containerName = $env:RT_TEST_NAME 11 | 12 | docker container run --platform linux --name $containerName $imageName 13 | if ($lastexitcode -ne 0) { 14 | exit 1 15 | } 16 | 17 | $output = [string] (& docker container inspect $containerName 2>&1) 18 | if ($lastexitcode -ne 0) { 19 | $output 20 | docker container rm --force $containerName 21 | exit 1 22 | } 23 | Write-Output "Output of docker inspect of the container:" 24 | $output | ConvertFrom-Json | ConvertTo-Json 25 | 26 | docker container rm --force $containerName 27 | if ($lastexitcode -ne 0) { 28 | exit 1 29 | } 30 | exit 0 31 | -------------------------------------------------------------------------------- /tests/cases/030_volume/010_local/010_create_inspect_remove/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create, inspect and remove a local volume 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | docker volume create -d local $env:RT_TEST_NAME 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | docker volume inspect $env:RT_TEST_NAME 17 | if ($lastexitcode -ne 0) { 18 | $ret = 1 19 | } 20 | 21 | docker volume rm $env:RT_TEST_NAME 22 | if ($lastexitcode -ne 0) { 23 | $ret = 1 24 | } 25 | 26 | exit $ret 27 | -------------------------------------------------------------------------------- /tests/cases/030_volume/010_local/020_use/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a local volume and use it in a container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | docker volume create -d local $env:RT_TEST_NAME 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | docker container run --platform linux --rm -v $env:RT_TEST_NAME`:/test alpine:3.7 touch /test/foobar 17 | if ($lastexitcode -ne 0) { 18 | $ret = 1 19 | } 20 | 21 | docker volume rm $env:RT_TEST_NAME 22 | if ($lastexitcode -ne 0) { 23 | $ret = 1 24 | } 25 | 26 | exit $ret 27 | -------------------------------------------------------------------------------- /tests/cases/030_volume/010_local/030_reuse/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a local volume and re-use it with two containers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | docker volume create -d local $env:RT_TEST_NAME 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | docker container run --platform linux --rm -v $env:RT_TEST_NAME`:/test alpine:3.7 touch /test/foobar 17 | if ($lastexitcode -ne 0) { 18 | $ret = 1 19 | } 20 | 21 | docker container run --platform linux --rm -v $env:RT_TEST_NAME`:/test alpine:3.7 test -f /test/foobar 22 | if ($lastexitcode -ne 0) { 23 | $ret = 1 24 | } 25 | 26 | docker volume rm $env:RT_TEST_NAME 27 | if ($lastexitcode -ne 0) { 28 | $ret = 1 29 | } 30 | 31 | exit $ret 32 | -------------------------------------------------------------------------------- /tests/cases/030_volume/010_local/040_share/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | file=$1 4 | 5 | # poll f0r 50 seconds for the file to appear 6 | retries=50 7 | while [ "${retries}" -ne 0 ]; do 8 | [ -f "$file" ] && exit 0 9 | sleep 1 10 | retries=$(( retries - 1 )) 11 | done 12 | exit 1 13 | -------------------------------------------------------------------------------- /tests/cases/030_volume/010_local/040_share/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a local volume and share it between two containers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $containerName = $env:RT_TEST_NAME 10 | $ret = 0 11 | 12 | docker volume create -d local $env:RT_TEST_NAME 13 | if ($lastexitcode -ne 0) { 14 | exit 1 15 | } 16 | 17 | # Start a container in the background which creates a file on a local volume 18 | docker container run --platform linux --rm -d --name $containerName ` 19 | -v $env:RT_TEST_NAME`:/test alpine:3.7 sh -c "touch /test/foobar; sleep 1000" 20 | 21 | # Start a second container which checks for the file 22 | $p = [string]$pwd.Path 23 | docker container run --platform linux --rm ` 24 | -v $env:RT_TEST_NAME`:/test ` 25 | -v $p`:/script ` 26 | alpine:3.7 sh /script/run.sh /test/foobar 27 | if ($lastexitcode -ne 0) { 28 | $ret = 1 29 | } 30 | 31 | # remove the background container 32 | docker container kill $containerName 33 | 34 | docker volume rm $env:RT_TEST_NAME 35 | if ($lastexitcode -ne 0) { 36 | $ret = 1 37 | } 38 | 39 | exit $ret 40 | -------------------------------------------------------------------------------- /tests/cases/030_volume/010_local/050_readonly/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a local volume and use it read-only in a container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | docker volume create -d local $env:RT_TEST_NAME 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | docker container run --platform linux --rm -v $env:RT_TEST_NAME`:/test:ro alpine:3.7 touch /test/foobar 17 | if ($lastexitcode -eq 0) { 18 | $ret = 1 19 | } 20 | 21 | docker volume rm $env:RT_TEST_NAME 22 | if ($lastexitcode -ne 0) { 23 | $ret = 1 24 | } 25 | 26 | exit $ret 27 | -------------------------------------------------------------------------------- /tests/cases/030_volume/010_local/100_mkfifo/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a fifo on a local volume 2 | # LABELS: 3 | # REPEAT: 4 | # 5 | # Some systems, like LCOW, may use different filesystems to 6 | # implement local volumes. This test is there to check some 7 | # more "excotic" operations one might do on a shared volume. 8 | 9 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 10 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 11 | . $lib 12 | 13 | $ret = 0 14 | 15 | docker volume create -d local $env:RT_TEST_NAME 16 | if ($lastexitcode -ne 0) { 17 | exit 1 18 | } 19 | 20 | docker container run --platform linux --rm -v $env:RT_TEST_NAME`:/test alpine:3.7 mkfifo /test/foobar 21 | if ($lastexitcode -ne 0) { 22 | $ret = 1 23 | } 24 | 25 | docker volume rm $env:RT_TEST_NAME 26 | if ($lastexitcode -ne 0) { 27 | $ret = 1 28 | } 29 | 30 | exit $ret 31 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/010_touch/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create (touch) a file on volume mount and check on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "touch /test/$fileName" 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | if (!(Test-Path $testPath -PathType leaf)) { 23 | $ret = 1 24 | } 25 | 26 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 27 | exit $ret 28 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/012_readonly/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Try to create a file on a read-only volume mount 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 12 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 13 | 14 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test:ro alpine:3.7 touch /test/foobar 15 | if ($lastexitcode -eq 0) { 16 | exit 1 17 | } 18 | 19 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 20 | exit $ret 21 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/015_echo/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a file on mounted volume and check contents on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "echo -n $fileName > /test/$fileName" 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | if (!(Test-Path $testPath -PathType leaf)) { 23 | $ret = 1 24 | } else { 25 | $content = Get-Content $testPath -Raw 26 | if ($content -ne $fileName) { 27 | $content 28 | $ret = 1 29 | } 30 | } 31 | 32 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 33 | exit $ret 34 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/020_mkdir/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a directory on a mounted volume and check on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "mkdir /test/$fileName" 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | if (!(Test-Path $testPath -PathType container)) { 23 | $ret = 1 24 | } 25 | 26 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 27 | exit $ret 28 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/022_mkdir_host/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a sub-directory on a mounted volume and check on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $baseName = "foobar" 12 | $fileName = "baz" 13 | 14 | $dirPath = Join-Path -Path $env:TEST_TMP -ChildPath $baseName 15 | $testPath = Join-Path -Path $dirPath -ChildPath $fileName 16 | 17 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 18 | New-Item -ItemType directory -Force -Path $dirPath 19 | 20 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "mkdir /test/$baseName/$fileName" 21 | if ($lastexitcode -ne 0) { 22 | exit 1 23 | } 24 | 25 | if (!(Test-Path $testPath -PathType container)) { 26 | $ret = 1 27 | } 28 | 29 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 30 | exit $ret 31 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/025_mkdir_p/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create directories on a mounted volume and check on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 1 10 | 11 | $dirName = "foo/bar" 12 | 13 | $tmp = Join-Path -Path $env:TEST_TMP -ChildPath foo 14 | $testPath = Join-Path -Path $tmp -ChildPath bar 15 | 16 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 17 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 18 | 19 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "mkdir -p /test/$dirName" 20 | if ($lastexitcode -ne 0) { 21 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 22 | exit 1 23 | } 24 | 25 | if (Test-Path $testPath -PathType container) { 26 | $ret = 0 27 | } 28 | 29 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 30 | exit $ret 31 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/030_rmdir_host/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Remove a subdir create on the host in a container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $dirName = "foobar" 12 | $dirPath = Join-Path -Path $env:TEST_TMP -ChildPath $dirName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $dirPath 16 | 17 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "rmdir /test/$dirName" 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | if (Test-Path $dirPath) { 23 | $ret = 1 24 | } 25 | 26 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 27 | exit $ret 28 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/035_rmdir_nonempty/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY rmdir_test.sh / 3 | RUN chmod ugo+x rmdir_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/035_rmdir_nonempty/rmdir_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | DIR=$1 7 | 8 | cd "$DIR" || exit 1 9 | rm -rf foo 10 | mkdir foo 11 | touch foo/bar 12 | (rmdir foo 2> output || true) 13 | cat output 14 | rm -rf foo 15 | grep "Directory not empty" output 16 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/035_rmdir_nonempty/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Try to remove a non-empty sub-directory on a mounted volume 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "output" 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker image build --platform linux -t $imageName . 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /rmdir_test.sh /test 23 | if ($lastexitcode -ne 0) { 24 | $ret = 1 25 | } 26 | 27 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/040_extended_ascii_name_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a file with extended ascii characters in the name on a volume mount and check on the host 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/docker/for-win/issues/986 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $fileName = "test-öäü.txt" 13 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 14 | 15 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 16 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 17 | 18 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "touch /test/$fileName" 19 | if ($lastexitcode -ne 0) { 20 | exit 1 21 | } 22 | 23 | if (!(Test-Path $testPath -PathType leaf)) { 24 | $ret = 1 25 | } 26 | 27 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/042_extended_ascii_name_host/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a file with extended ascii characters on the host and check in a container 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/docker/for-win/issues/986 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $fileName = "test-öäü.txt" 13 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 14 | 15 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 16 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 17 | 18 | New-Item -ItemType File -Path $testPath 19 | 20 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "test -f /test/$fileName" 21 | if ($lastexitcode -ne 0) { 22 | $ret = 1 23 | } 24 | 25 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 26 | exit $ret 27 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/044_unicode_name_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a file with unicode characters in the name on a volume mount and check on the host 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/docker/for-win/issues/986 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | # based on: http://www.columbia.edu/~fdc/utf8/ 13 | $fileName = "test-我能吞下.txt" 14 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 15 | 16 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 17 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 18 | 19 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "touch /test/$fileName" 20 | if ($lastexitcode -ne 0) { 21 | exit 1 22 | } 23 | 24 | if (!(Test-Path $testPath -PathType leaf)) { 25 | $ret = 1 26 | } 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/046_unicode_name_host/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a file with unicode characters on the host and check in a container 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/docker/for-win/issues/986 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | # based on: http://www.columbia.edu/~fdc/utf8/ 13 | $fileName = "test-我能吞下.txt" 14 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 15 | 16 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 17 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 18 | 19 | New-Item -ItemType File -Path $testPath 20 | 21 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 sh -c "test -f /test/$fileName" 22 | if ($lastexitcode -ne 0) { 23 | $ret = 1 24 | } 25 | 26 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 27 | exit $ret 28 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/050_flock_volume/check_flock.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | FILE=$1 7 | ret=0 8 | 9 | # First check that flock works 10 | flock -x "$FILE" echo "flock works" 11 | 12 | # disable exit on error as we expect an error below 13 | set +e 14 | 15 | # start a background process locking a file 16 | flock -x "$FILE" sleep 1000 & 17 | pid=$! 18 | 19 | # try to lock the file 20 | flock -xn "$FILE" echo "locked although locked" 21 | res=$? 22 | [ $res -eq 0 ] && $ret = 1 # If we did not get an error this test failed 23 | 24 | # clean up 25 | kill $pid 26 | flock -u "$FILE" echo "unlocked" 27 | 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/050_flock_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check that flock() works on a shared volume 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/moby/moby/issues/36531#issuecomment-372020535 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $fileName = "lockfile" 13 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 14 | 15 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 16 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 17 | 18 | $p = [string]$pwd.Path 19 | docker container run --platform linux --rm ` 20 | -v $env:TEST_TMP`:/test ` 21 | -v $p`:/script ` 22 | -e TZ=UTC alpine:3.7 sh /script/check_flock.sh /test/$fileName 23 | if ($lastexitcode -ne 0) { 24 | $ret = 1 25 | } 26 | 27 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/052_flock_volume_containers/check_flock.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -x 4 | 5 | FILE=$1 6 | ret=0 7 | 8 | # start a background process locking a file 9 | flock -x "$FILE" sleep 1000 & 10 | pid=$! 11 | 12 | # try to lock the file 13 | flock -xn "$FILE" echo "locked although locked" 14 | res=$? 15 | [ $res -eq 0 ] && $ret = 1 # If we did not get an error this test failed 16 | 17 | # clean up 18 | kill $pid 19 | flock -u "$FILE" echo "unlocked" 20 | 21 | exit $ret 22 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/052_flock_volume_containers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check that flock() works between containers sharing the same volume 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/moby/moby/issues/36531#issuecomment-372020535 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $fileName = "lockfile" 13 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 14 | $containerName = $env:RT_TEST_NAME 15 | 16 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 17 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 18 | 19 | # Check that flock works first 20 | docker container run --platform linux --rm --name $containerName -v $env:TEST_TMP`:/test alpine:3.7 ` 21 | flock -x /test/$fileName echo "flock works" 22 | if ($lastexitcode -ne 0) { 23 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 24 | exit 1 25 | } 26 | 27 | # Start a container in the background which locks the file 28 | docker container run --platform linux --rm -d --name $containerName -v $env:TEST_TMP`:/test alpine:3.7 ` 29 | flock -x /test/$fileName sleep 1000 30 | 31 | # Start another container trying to lock the same file. This should fail 32 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 ` 33 | flock -xn /test/$fileName echo "locked although locked" 34 | if ($lastexitcode -eq 0) { 35 | $ret = 1 36 | } 37 | 38 | # remove the background container 39 | docker container kill $containerName 40 | 41 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 42 | exit $ret 43 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/060_symlink_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY symlink_test.sh / 3 | RUN chmod ugo+x symlink_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/060_symlink_volume/symlink_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | FILE=$1 7 | LINK=$2 8 | CONTENT="foo" 9 | 10 | echo "$CONTENT" > $FILE 11 | ln -s "$FILE" "$LINK" 12 | 13 | if [[ $(readlink "$LINK") != "$FILE" ]]; then 14 | echo "Symlink $LINK is not pointing to $FILE" 15 | exit 1 16 | fi 17 | 18 | if [[ $(cat "$LINK") != "$CONTENT" ]]; then 19 | echo "Contents don't match" 20 | exit 1 21 | fi 22 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/060_symlink_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a symlink on a volume mount and check in container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "foobar" 13 | $linkName = "barfoo" 14 | 15 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 16 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 17 | 18 | docker image build --platform linux -t $imageName . 19 | if ($lastexitcode -ne 0) { 20 | exit 1 21 | } 22 | 23 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /symlink_test.sh /test/$fileName /test/$linkName 24 | 25 | if ($lastexitcode -ne 0) { 26 | $ret = 1 27 | } 28 | 29 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 30 | exit $ret 31 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/065_hardlink_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY hardlink_test.sh / 3 | RUN chmod ugo+x hardlink_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/065_hardlink_volume/hardlink_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | FILE=$1 7 | LINK=$2 8 | CONTENT="foo" 9 | 10 | echo "$CONTENT" > $FILE 11 | ln "$FILE" "$LINK" 12 | 13 | if [[ $(stat -c %h "$FILE") != $(stat -c %h "$LINK") ]]; then 14 | echo "Number of hardlinks don't match" 15 | exit 1 16 | fi 17 | 18 | if [[ $(stat -c %i "$FILE") != $(stat -c %i "$LINK") ]]; then 19 | echo "Inode numbers don't match" 20 | exit 1 21 | fi 22 | 23 | if [[ $(stat -c %h "$FILE") <= 1 ]]; then 24 | echo "$FILE should Number of hardlinks greater than 1" 25 | exit 1 26 | fi 27 | 28 | if [[ $(cat "$LINK") != "$CONTENT" ]]; then 29 | echo "Contents don't match" 30 | exit 1 31 | fi 32 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/065_hardlink_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a hard link on a volume mount and check in container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "foobar" 13 | $linkName = "barfoo" 14 | 15 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 16 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 17 | 18 | docker image build --platform linux -t $imageName . 19 | if ($lastexitcode -ne 0) { 20 | exit 1 21 | } 22 | 23 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /hardlink_test.sh /test/$fileName /test/$linkName 24 | if ($lastexitcode -ne 0) { 25 | $ret = 1 26 | } 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/070_socket_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | RUN apk add --no-cache netcat-openbsd 3 | COPY socket_test.sh / 4 | RUN chmod ugo+x socket_test.sh 5 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/070_socket_volume/socket_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | FILE=$1 7 | 8 | nc -lU "$FILE" & 9 | pid=$! 10 | 11 | sleep 1 12 | 13 | TYPE=$(stat -c %F "$FILE") 14 | 15 | kill "$pid" 16 | 17 | if [ "$TYPE" != "socket" ]; then 18 | echo "$FILE is not a unix domain socket: $TYPE != socket" 19 | exit 1 20 | fi 21 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/070_socket_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a unix domain socket a volume mount and check in container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "foobar" 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker image build --platform linux -t $imageName . 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /socket_test.sh /test/$fileName 23 | 24 | if ($lastexitcode -ne 0) { 25 | $ret = 1 26 | } 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/075_mkfifo_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY mkfifo_test.sh / 3 | RUN chmod ugo+x mkfifo_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/075_mkfifo_volume/mkfifo_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | FILE=$1 7 | 8 | mkfifo "$FILE" 9 | 10 | TYPE=$(stat -c %F "$FILE") 11 | if [ "$TYPE" != "fifo" ]; then 12 | echo "$FILE is not a fifo: $TYPE != fifo" 13 | exit 1 14 | fi 15 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/075_mkfifo_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a fifo on a volume mount and check in container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "foobar" 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker image build --platform linux -t $imageName . 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /mkfifo_test.sh /test/$fileName 23 | if ($lastexitcode -ne 0) { 24 | $ret = 1 25 | } 26 | 27 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/090_mount_file/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Volume mount a single file into container 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/moby/moby/issues/35425 5 | # ISSUE: https://github.com/docker/for-win/issues/1360 6 | 7 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 8 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 9 | . $lib 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | Get-Date | Set-Content $testPath 18 | 19 | docker container run --platform linux --rm -v $testPath`:/test alpine:3.7 sh -c "cat test" 20 | if ($lastexitcode -ne 0) { 21 | exit 1 22 | } 23 | 24 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 25 | exit 0 26 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/095_mount_docker_socket/socket-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | apk add --no-cache curl 7 | curl -XGET --unix-socket /var/run/docker.sock http://localhost/images/json 8 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/095_mount_docker_socket/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Volume mount a single file into container 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/moby/moby/issues/35425 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $p = [string]$pwd.Path 11 | docker container run --platform linux --rm ` 12 | -v /var/run/docker.sock:/var/run/docker.sock ` 13 | -v $p`:/test ` 14 | alpine:3.7 sh /test/socket-test.sh 15 | if ($lastexitcode -ne 0) { 16 | exit 1 17 | } 18 | 19 | exit 0 20 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/100_chown_file_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY chown_test.sh / 3 | RUN chmod ugo+x chown_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/100_chown_file_volume/chown_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | # This script tests a number of combination of chown of files. It does 7 | # *not* error on the first error, instead all tests are run. 8 | 9 | FILE=$1 10 | ret=0 11 | 12 | echo 13 | TEST="chown file uid only (nobody)" 14 | rm -rf "$FILE" 15 | touch "$FILE" 16 | chown nobody "$FILE" 17 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 18 | EXPECTED="nobody:root" 19 | if [ "$EXPECTED" != "$RESULT" ]; then 20 | echo "$TEST: expected $EXPECTED got $RESULT" 21 | ret=1 22 | fi 23 | 24 | echo 25 | TEST="chown file uid only (postgres)" 26 | rm -rf "$FILE" 27 | touch "$FILE" 28 | chown postgres "$FILE" 29 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 30 | EXPECTED="postgres:root" 31 | if [ "$EXPECTED" != "$RESULT" ]; then 32 | echo "$TEST: expected $EXPECTED got $RESULT" 33 | ret=1 34 | fi 35 | 36 | echo 37 | TEST="chown file uid only (root)" 38 | rm -rf "$FILE" 39 | touch "$FILE" 40 | chown root "$FILE" 41 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 42 | EXPECTED="root:root" 43 | if [ "$EXPECTED" != "$RESULT" ]; then 44 | echo "$TEST: expected $EXPECTED got $RESULT" 45 | ret=1 46 | fi 47 | 48 | echo 49 | TEST="chown file gid only (nobody)" 50 | rm -rf "$FILE" 51 | touch "$FILE" 52 | chown :nobody "$FILE" 53 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 54 | EXPECTED="root:nobody" 55 | if [ "$EXPECTED" != "$RESULT" ]; then 56 | echo "$TEST: expected $EXPECTED got $RESULT" 57 | ret=1 58 | fi 59 | 60 | echo 61 | TEST="chown file gid only (postgres)" 62 | rm -rf "$FILE" 63 | touch "$FILE" 64 | chown :postgres "$FILE" 65 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 66 | EXPECTED="root:postgres" 67 | if [ "$EXPECTED" != "$RESULT" ]; then 68 | echo "$TEST: expected $EXPECTED got $RESULT" 69 | ret=1 70 | fi 71 | 72 | echo 73 | TEST="chown file gid only (root)" 74 | rm -rf "$FILE" 75 | touch "$FILE" 76 | chown :root "$FILE" 77 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 78 | EXPECTED="root:root" 79 | if [ "$EXPECTED" != "$RESULT" ]; then 80 | echo "$TEST: expected $EXPECTED got $RESULT" 81 | ret=1 82 | fi 83 | 84 | echo 85 | TEST="chown file uid and gid (nobody)" 86 | rm -rf "$FILE" 87 | touch "$FILE" 88 | chown nobody:nobody "$FILE" 89 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 90 | EXPECTED="nobody:nobody" 91 | if [ "$EXPECTED" != "$RESULT" ]; then 92 | echo "$TEST: expected $EXPECTED got $RESULT" 93 | ret=1 94 | fi 95 | 96 | echo 97 | TEST="chown file uid and gid (postgres)" 98 | rm -rf "$FILE" 99 | touch "$FILE" 100 | chown postgres:postgres "$FILE" 101 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 102 | EXPECTED="postgres:postgres" 103 | if [ "$EXPECTED" != "$RESULT" ]; then 104 | echo "$TEST: expected $EXPECTED got $RESULT" 105 | ret=1 106 | fi 107 | 108 | echo 109 | TEST="chown file uid and gid (root)" 110 | rm -rf "$FILE" 111 | touch "$FILE" 112 | chown root:root "$FILE" 113 | RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 114 | EXPECTED="root:root" 115 | if [ "$EXPECTED" != "$RESULT" ]; then 116 | echo "$TEST: expected $EXPECTED got $RESULT" 117 | ret=1 118 | fi 119 | 120 | exit $ret 121 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/100_chown_file_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check permutations of chown on a file on a volume mount in a container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "foobar" 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker image build --platform linux -t $imageName . 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /chown_test.sh /test/$fileName 23 | if ($lastexitcode -ne 0) { 24 | $ret = 1 25 | } 26 | 27 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/105_chown_symlink_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY chown_test.sh / 3 | RUN chmod ugo+x chown_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/105_chown_symlink_volume/chown_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | # This script tests a number of combination of chown of symlink. It does 7 | # *not* error on the first error, instead all tests are run. 8 | 9 | FILE=$1 10 | LINK=$2 11 | ret=0 12 | 13 | touch "$FILE" 14 | # We use 'chown -h' below so expect only the symlink but not 15 | # the real file to change. 16 | FILE_EXPECTED=$(su -c "stat -c %U:%G $FILE" postgres) 17 | 18 | echo 19 | TEST="chown symlink uid only (nobody)" 20 | rm -rf "$LINK" 21 | ln -s "$FILE" "$LINK" 22 | chown -h nobody "$LINK" 23 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 24 | EXPECTED="nobody:root" 25 | if [ "$EXPECTED" != "$RESULT" ]; then 26 | echo "$TEST: expected $EXPECTED got $RESULT" 27 | ret=1 28 | fi 29 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 30 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 31 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 32 | ret=1 33 | fi 34 | 35 | echo 36 | TEST="chown symlink uid only (postgres)" 37 | rm -rf "$LINK" 38 | ln -s "$FILE" "$LINK" 39 | chown -h postgres "$LINK" 40 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 41 | EXPECTED="postgres:root" 42 | if [ "$EXPECTED" != "$RESULT" ]; then 43 | echo "$TEST: expected $EXPECTED got $RESULT" 44 | ret=1 45 | fi 46 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 47 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 48 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 49 | ret=1 50 | fi 51 | 52 | echo 53 | TEST="chown symlink uid only (root)" 54 | rm -rf "$LINK" 55 | ln -s "$FILE" "$LINK" 56 | chown -h root "$LINK" 57 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 58 | EXPECTED="root:root" 59 | if [ "$EXPECTED" != "$RESULT" ]; then 60 | echo "$TEST: expected $EXPECTED got $RESULT" 61 | ret=1 62 | fi 63 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 64 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 65 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 66 | ret=1 67 | fi 68 | 69 | echo 70 | TEST="chown symlink gid only (nobody)" 71 | rm -rf "$LINK" 72 | ln -s "$FILE" "$LINK" 73 | chown -h :nobody "$LINK" 74 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 75 | EXPECTED="root:nobody" 76 | if [ "$EXPECTED" != "$RESULT" ]; then 77 | echo "$TEST: expected $EXPECTED got $RESULT" 78 | ret=1 79 | fi 80 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 81 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 82 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 83 | ret=1 84 | fi 85 | 86 | echo 87 | TEST="chown symlink gid only (postgres)" 88 | rm -rf "$LINK" 89 | ln -s "$FILE" "$LINK" 90 | chown -h :postgres "$LINK" 91 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 92 | EXPECTED="root:postgres" 93 | if [ "$EXPECTED" != "$RESULT" ]; then 94 | echo "$TEST: expected $EXPECTED got $RESULT" 95 | ret=1 96 | fi 97 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 98 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 99 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 100 | ret=1 101 | fi 102 | 103 | echo 104 | TEST="chown symlink gid only (root)" 105 | rm -rf "$LINK" 106 | ln -s "$FILE" "$LINK" 107 | chown -h :root "$LINK" 108 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 109 | EXPECTED="root:root" 110 | if [ "$EXPECTED" != "$RESULT" ]; then 111 | echo "$TEST: expected $EXPECTED got $RESULT" 112 | ret=1 113 | fi 114 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 115 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 116 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 117 | ret=1 118 | fi 119 | 120 | echo 121 | TEST="chown symlink uid and gid (nobody)" 122 | rm -rf "$LINK" 123 | ln -s "$FILE" "$LINK" 124 | chown -h nobody:nobody "$LINK" 125 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 126 | EXPECTED="nobody:nobody" 127 | if [ "$EXPECTED" != "$RESULT" ]; then 128 | echo "$TEST: expected $EXPECTED got $RESULT" 129 | ret=1 130 | fi 131 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 132 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 133 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 134 | ret=1 135 | fi 136 | 137 | echo 138 | TEST="chown symlink uid and gid (postgres)" 139 | rm -rf "$LINK" 140 | ln -s "$FILE" "$LINK" 141 | chown -h postgres:postgres "$LINK" 142 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 143 | EXPECTED="postgres:postgres" 144 | if [ "$EXPECTED" != "$RESULT" ]; then 145 | echo "$TEST: expected $EXPECTED got $RESULT" 146 | ret=1 147 | fi 148 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 149 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 150 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 151 | ret=1 152 | fi 153 | 154 | echo 155 | TEST="chown symlink uid and gid (root)" 156 | rm -rf "$LINK" 157 | ln -s "$FILE" "$LINK" 158 | chown -h root:root "$LINK" 159 | RESULT=$(su -c "stat -c %U:%G $LINK" postgres) 160 | EXPECTED="root:root" 161 | if [ "$EXPECTED" != "$RESULT" ]; then 162 | echo "$TEST: expected $EXPECTED got $RESULT" 163 | ret=1 164 | fi 165 | FILE_RESULT=$(su -c "stat -c %U:%G $FILE" postgres) 166 | if [ "$FILE_EXPECTED" != "$FILE_RESULT" ]; then 167 | echo "$TEST: expected $EXPECTED got $RESULT on real file" 168 | ret=1 169 | fi 170 | 171 | exit $ret 172 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/105_chown_symlink_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check permutations of chown on a symlink on a volume mount in a container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "foobar" 13 | $linkName = "barfoo" 14 | 15 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 16 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 17 | 18 | docker image build --platform linux -t $imageName . 19 | if ($lastexitcode -ne 0) { 20 | exit 1 21 | } 22 | 23 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /chown_test.sh /test/$fileName /test/$linkName 24 | if ($lastexitcode -ne 0) { 25 | $ret = 1 26 | } 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/110_chmod_file_mode_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY chmod_test.sh / 3 | RUN chmod ugo+x chmod_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/110_chmod_file_mode_volume/chmod_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | # This script tests a number of combination of chmod of files. It does 7 | # *not* error on the first error, instead all tests are run. 8 | 9 | FILE=$1 10 | CONTENT="foo" 11 | ret=0 12 | 13 | echo 14 | TEST="chmod file r/w user only" 15 | rm -rf "$FILE" 16 | echo "CONTENT" > "$FILE" 17 | chmod 0600 "$FILE" 18 | RESULT=$(stat -c %a "$FILE") 19 | EXPECTED="600" 20 | if [ "$EXPECTED" != "$RESULT" ]; then 21 | echo "$TEST: expected $EXPECTED got $RESULT" 22 | ret=1 23 | fi 24 | 25 | echo 26 | TEST="chmod file r/x user only" 27 | rm -rf "$FILE" 28 | echo "CONTENT" > "$FILE" 29 | chmod 0500 "$FILE" 30 | RESULT=$(stat -c %a "$FILE") 31 | EXPECTED="500" 32 | if [ "$EXPECTED" != "$RESULT" ]; then 33 | echo "$TEST: expected $EXPECTED got $RESULT" 34 | ret=1 35 | fi 36 | 37 | echo 38 | TEST="chmod file r/w/x user r/x for group" 39 | rm -rf "$FILE" 40 | echo "CONTENT" > "$FILE" 41 | chmod 0750 "$FILE" 42 | RESULT=$(stat -c %a "$FILE") 43 | EXPECTED="750" 44 | if [ "$EXPECTED" != "$RESULT" ]; then 45 | echo "$TEST: expected $EXPECTED got $RESULT" 46 | ret=1 47 | fi 48 | 49 | echo 50 | TEST="chmod file r/w/x user r/x for group/other" 51 | rm -rf "$FILE" 52 | echo "CONTENT" > "$FILE" 53 | chmod 0755 "$FILE" 54 | RESULT=$(stat -c %a "$FILE") 55 | EXPECTED="755" 56 | if [ "$EXPECTED" != "$RESULT" ]; then 57 | echo "$TEST: expected $EXPECTED got $RESULT" 58 | ret=1 59 | fi 60 | 61 | echo 62 | TEST="chmod file setuid+r/w/x user r/x group/other" 63 | rm -rf "$FILE" 64 | echo "CONTENT" > "$FILE" 65 | chmod 4755 "$FILE" 66 | RESULT=$(stat -c %a "$FILE") 67 | EXPECTED="4755" 68 | if [ "$EXPECTED" != "$RESULT" ]; then 69 | echo "$TEST: expected $EXPECTED got $RESULT" 70 | ret=1 71 | fi 72 | 73 | echo 74 | TEST="chmod file setgid+r/w/x user r/x group/other" 75 | rm -rf "$FILE" 76 | echo "CONTENT" > "$FILE" 77 | chmod 2755 "$FILE" 78 | RESULT=$(stat -c %a "$FILE") 79 | EXPECTED="2755" 80 | if [ "$EXPECTED" != "$RESULT" ]; then 81 | echo "$TEST: expected $EXPECTED got $RESULT" 82 | ret=1 83 | fi 84 | 85 | exit $ret 86 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/110_chmod_file_mode_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check changes to a file mode (chmod) on a volume mount in a container 2 | # LABELS: 3 | # REPEAT: 4 | # ISSUE: https://github.com/moby/moby/issues/35665 5 | 6 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 7 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 8 | . $lib 9 | 10 | $ret = 0 11 | 12 | $imageName = $env:RT_TEST_NAME 13 | $fileName = "foobar" 14 | 15 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 16 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 17 | 18 | docker image build --platform linux -t $imageName . 19 | if ($lastexitcode -ne 0) { 20 | exit 1 21 | } 22 | 23 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /chmod_test.sh /test/$fileName 24 | if ($lastexitcode -ne 0) { 25 | $ret = 1 26 | } 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/120_chmod_file_access_volume/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY chmod_test.sh / 3 | RUN chmod ugo+x chmod_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/120_chmod_file_access_volume/chmod_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | FILE=$1 7 | CONTENT="foo" 8 | CONTENT2="foo2" 9 | ret=0 10 | 11 | adduser -D testuser 12 | adduser -D testuser2 13 | adduser testuser daemon 14 | 15 | rm -rf "$FILE" 16 | echo "$CONTENT" > "$FILE" 17 | chmod 0600 "$FILE" 18 | chown root:daemon "$FILE" 19 | 20 | echo 21 | TEST="file r/w root user only. Read access as root" 22 | RESULT=$(cat "$FILE") 23 | if [ "$CONTENT" != "$RESULT" ]; then 24 | echo "$TEST: expected $CONTENT got $RESULT" 25 | ret=1 26 | fi 27 | 28 | echo 29 | TEST="file r/w root user only. Write access as root" 30 | echo "$CONTENT2" > "$FILE" 31 | RESULT=$(cat "$FILE") 32 | if [ "$CONTENT2" != "$RESULT" ]; then 33 | echo "$TEST: expected $CONTENT2 got $RESULT" 34 | ret=1 35 | fi 36 | 37 | echo 38 | TEST="file r/w root user only. Read access as testuser" 39 | set +e 40 | su -c "cat $FILE" testuser 41 | res=$? 42 | set -e 43 | if [ "$res" != "1" ]; then 44 | echo "$TEST: expected it to fail" 45 | ret=1 46 | fi 47 | 48 | echo 49 | TEST="file r/w root user only. Write access as testuser" 50 | set +e 51 | su -c "echo $CONTENT > $FILE" testuser 52 | res=$? 53 | set -e 54 | if [ "$res" != "1" ]; then 55 | echo "$TEST: expected it to fail" 56 | ret=1 57 | fi 58 | 59 | echo 60 | TEST="file r/w root user only. Read access as testuser2" 61 | set +e 62 | su -c "cat $FILE" testuser2 63 | res=$? 64 | set -e 65 | if [ "$res" != "1" ]; then 66 | echo "$TEST: expected it to fail" 67 | ret=1 68 | fi 69 | 70 | echo 71 | TEST="file r/w root user only. Write access as testuser2" 72 | set +e 73 | su -c "echo $CONTENT > $FILE" testuser2 74 | res=$? 75 | set -e 76 | if [ "$res" != "1" ]; then 77 | echo "$TEST: expected it to fail" 78 | ret=1 79 | fi 80 | 81 | # change to allow group access 82 | rm -rf "$FILE" 83 | echo "$CONTENT" > "$FILE" 84 | chmod 0660 "$FILE" 85 | chown root:daemon "$FILE" 86 | 87 | echo 88 | TEST="file r/w user/group only. Read access as testuser" 89 | RESULT=$(su -c "cat $FILE" testuser) 90 | if [ "$CONTENT" != "$RESULT" ]; then 91 | echo "$TEST: expected $CONTENT got $RESULT" 92 | ret=1 93 | fi 94 | 95 | echo 96 | TEST="file r/w user/group only. Write access as testuser" 97 | su -c "echo $CONTENT2 > $FILE" testuser 98 | RESULT=$(cat "$FILE") 99 | if [ "$CONTENT2" != "$RESULT" ]; then 100 | echo "$TEST: expected $CONTENT2 got $RESULT" 101 | ret=1 102 | fi 103 | 104 | echo 105 | TEST="file r/w root user only. Read access as testuser2" 106 | set +e 107 | su -c "cat $FILE" testuser2 108 | res=$? 109 | set -e 110 | if [ "$res" != "1" ]; then 111 | echo "$TEST: expected it to fail" 112 | ret=1 113 | fi 114 | 115 | echo 116 | TEST="file r/w root user only. Write access as testuser2" 117 | set +e 118 | su -c "echo $CONTENT > $FILE" testuser2 119 | res=$? 120 | set -e 121 | if [ "$res" != "1" ]; then 122 | echo "$TEST: expected it to fail" 123 | ret=1 124 | fi 125 | 126 | exit $ret 127 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/120_chmod_file_access_volume/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check file access a volume mount in a container 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $imageName = $env:RT_TEST_NAME 12 | $fileName = "foobar" 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | docker image build --platform linux -t $imageName . 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | docker container run --rm -v $env:TEST_TMP`:/test $imageName /chmod_test.sh /test/$fileName 23 | if ($lastexitcode -ne 0) { 24 | $ret = 1 25 | } 26 | 27 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 28 | exit $ret 29 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/150_utime/check_time.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | FILE=$1 7 | 8 | ts=$(stat -c %Y "$FILE") 9 | if [ "$ts" == "0" ]; then 10 | exit 0 11 | fi 12 | exit 1 13 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/150_utime/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Check file access time 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | # 18 | # Create a file in a container and check on the host 19 | # 20 | docker container run --rm -v $env:TEST_TMP`:/test -e TZ=UTC alpine:3.7 touch -t 197002010000.00 /test/$fileName 21 | 22 | # check timestamp 23 | $expected = Get-Date -Date "1970-02-01 00:00:00Z" 24 | $result = [datetime](Get-ItemProperty -Path $testPath -Name LastWriteTime).lastwritetime 25 | if ($expected -ne $result) { 26 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 27 | exit 1 28 | } 29 | 30 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 31 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 32 | 33 | # 34 | # Create a file on the host and check in a container 35 | # 36 | $ts = Get-Date -Date "1970-01-01 00:00:00Z" 37 | New-Item -ItemType File -Path $testPath 38 | Set-ItemProperty -Path $testPath -Name LastWriteTime -Value $ts 39 | # XXX This relies on the numeric time stamp being 0 40 | $p = [string]$pwd.Path 41 | docker container run --platform linux --rm ` 42 | -v $env:TEST_TMP`:/test ` 43 | -v $p`:/script ` 44 | -e TZ=UTC alpine:3.7 sh /script/check_time.sh /test/$fileName 45 | if ($lastexitcode -ne 0) { 46 | $ret = 1 47 | } 48 | 49 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 50 | exit $ret 51 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/200_statfs/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | COPY statfs_test.sh / 3 | RUN chmod ugo+x statfs_test.sh 4 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/200_statfs/statfs_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -x 5 | 6 | DIR=$1 7 | ret=0 8 | 9 | R=$(stat -f -c %t "$DIR") 10 | if [ "$R" == "0" ]; then 11 | echo "Volume does not support reporting type" 12 | ret=1 13 | fi 14 | 15 | R=$(stat -f -c %s "$DIR") 16 | if [ "$R" == "0" ]; then 17 | echo "Volume does not support reporting blocksize" 18 | ret=1 19 | fi 20 | 21 | R=$(stat -f -c %a "$DIR") 22 | if [ "$R" == "0" ]; then 23 | echo "Volume does not support reporting blocksize" 24 | ret=1 25 | fi 26 | 27 | R=$(stat -f -c %b "$DIR") 28 | if [ "$R" == "0" ]; then 29 | echo "Volume does not support reporting total data blocks" 30 | ret=1 31 | fi 32 | 33 | R=$(stat -f -c %c "$DIR") 34 | if [ "$R" == "0" ]; then 35 | echo "Volume does not support reporting total file nodes" 36 | ret=1 37 | fi 38 | 39 | R=$(stat -f -c %d "$DIR") 40 | if [ "$R" == "0" ]; then 41 | echo "Volume does not support reporting free file nodes" 42 | ret=1 43 | fi 44 | 45 | R=$(stat -f -c %f "$DIR") 46 | if [ "$R" == "0" ]; then 47 | echo "Volume does not support reporting free blocks" 48 | ret=1 49 | fi 50 | 51 | R=$(stat -f -c %l "$DIR") 52 | if [ "$R" == "0" ]; then 53 | echo "Volume does not support reporting maximum length of filenames" 54 | ret=1 55 | fi 56 | 57 | return $ret 58 | -------------------------------------------------------------------------------- /tests/cases/100_hostvol/200_statfs/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Verify that volume mounts implement statfs 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | 11 | docker image build --platform linux -t $imageName . 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | $p = [string]$pwd.Path 17 | docker container run --rm -v $p`:/test $imageName /statfs_test.sh /test 18 | if ($lastexitcode -ne 0) { 19 | exit 1 20 | } 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/cases/110_hostnet/010_localhost/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Simple test with localhost networking 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $containerID = (& docker container run --platform linux -d --rm -p 8080:80 nginx) 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | $containerID 16 | 17 | for ($count = 1; $count -le 10; $count++) { 18 | try { 19 | $output = Invoke-WebRequest -UseBasicParsing http://localhost:8080 20 | } catch { 21 | Start-Sleep -Seconds 1 22 | continue 23 | } 24 | break 25 | } 26 | Write-Output "Output from request:" 27 | $output 28 | 29 | # check if we got the nginx 30 | $tmp = $output | select-string "Welcome to nginx!" -SimpleMatch 31 | if ($tmp.length -eq 0) { 32 | $ret = 1 33 | } 34 | 35 | docker container kill $containerID 36 | exit $ret 37 | -------------------------------------------------------------------------------- /tests/cases/200_compose/010_hello_world/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "2.4" 2 | services: 3 | test: 4 | image: hello-world 5 | platform: linux 6 | -------------------------------------------------------------------------------- /tests/cases/200_compose/010_hello_world/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Run a docker-compose based hello-world 2 | # LABELS: skip 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | docker-compose pull 12 | if ($lastexitcode -ne 0) { 13 | exit 1 14 | } 15 | 16 | $output = [string] (& docker-compose up 2>&1) 17 | if ($lastexitcode -ne 0) { 18 | $output 19 | $ret = 1 20 | } 21 | $output 22 | 23 | $tmp = $output | select-string "Hello from Docker!" -SimpleMatch 24 | if ($tmp.length -eq 0) { 25 | $ret = 1 26 | } 27 | 28 | docker-compose stop 29 | if ($lastexitcode -ne 0) { 30 | $ret = 1 31 | } 32 | 33 | docker-compose down --rmi all 34 | if ($lastexitcode -ne 0) { 35 | $ret = 1 36 | } 37 | 38 | exit $ret 39 | -------------------------------------------------------------------------------- /tests/cases/300_apps/placeholder: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/linuxkit/lcow/f926f46d1c5952024c251560a12fc50086cf1b62/tests/cases/300_apps/placeholder -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/010_pull/010_1_layer/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Pull an image with one layer 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = "linuxkit/test-lcow:1layer" 10 | 11 | docker rmi $imageName 12 | 13 | $start = Get-Date 14 | 15 | docker image pull --platform linux $imageName 16 | if ($lastexitcode -ne 0) { exit 1 } 17 | 18 | $end = Get-Date 19 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 20 | Write-Output "RT_BENCHMARK_RESULT: $diff" 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/010_pull/012_5_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Pull an image with five layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = "linuxkit/test-lcow:5layers" 10 | 11 | docker rmi $imageName 12 | 13 | $start = Get-Date 14 | 15 | docker image pull --platform linux $imageName 16 | if ($lastexitcode -ne 0) { exit 1 } 17 | 18 | $end = Get-Date 19 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 20 | Write-Output "RT_BENCHMARK_RESULT: $diff" 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/010_pull/014_10_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Pull an image with ten layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = "linuxkit/test-lcow:10layers" 10 | 11 | docker rmi $imageName 12 | 13 | $start = Get-Date 14 | 15 | docker image pull --platform linux $imageName 16 | if ($lastexitcode -ne 0) { exit 1 } 17 | 18 | $end = Get-Date 19 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 20 | Write-Output "RT_BENCHMARK_RESULT: $diff" 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/010_pull/016_15_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Pull an image with fifteen layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = "linuxkit/test-lcow:15layers" 10 | 11 | docker rmi $imageName 12 | 13 | $start = Get-Date 14 | 15 | docker image pull --platform linux $imageName 16 | if ($lastexitcode -ne 0) { exit 1 } 17 | 18 | $end = Get-Date 19 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 20 | Write-Output "RT_BENCHMARK_RESULT: $diff" 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/010_pull/018_20_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Pull an image with twenty layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = "linuxkit/test-lcow:20layers" 10 | 11 | docker rmi $imageName 12 | 13 | $start = Get-Date 14 | 15 | docker image pull --platform linux $imageName 16 | if ($lastexitcode -ne 0) { exit 1 } 17 | 18 | $end = Get-Date 19 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 20 | Write-Output "RT_BENCHMARK_RESULT: $diff" 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/012_5_layers/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | # FROM alpine counts as one layer 3 | RUN dd if=/dev/urandom of=file-01 bs=8 count=1 4 | RUN dd if=/dev/urandom of=file-02 bs=8 count=1 5 | RUN dd if=/dev/urandom of=file-03 bs=8 count=1 6 | RUN dd if=/dev/urandom of=file-04 bs=8 count=1 7 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/012_5_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Build an image with five layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | 11 | $start = Get-Date 12 | 13 | docker image build --no-cache --network none --platform linux -t $imageName . 14 | if ($lastexitcode -ne 0) { exit 1 } 15 | 16 | $end = Get-Date 17 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 18 | Write-Output "RT_BENCHMARK_RESULT: $diff" 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/014_10_layers/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | # FROM alpine counts as one layer 3 | RUN dd if=/dev/urandom of=file-01 bs=8 count=1 4 | RUN dd if=/dev/urandom of=file-02 bs=8 count=1 5 | RUN dd if=/dev/urandom of=file-03 bs=8 count=1 6 | RUN dd if=/dev/urandom of=file-04 bs=8 count=1 7 | 8 | RUN dd if=/dev/urandom of=file-05 bs=8 count=1 9 | RUN dd if=/dev/urandom of=file-06 bs=8 count=1 10 | RUN dd if=/dev/urandom of=file-07 bs=8 count=1 11 | RUN dd if=/dev/urandom of=file-08 bs=8 count=1 12 | RUN dd if=/dev/urandom of=file-09 bs=8 count=1 13 | 14 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/014_10_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Build an image with ten layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | 11 | $start = Get-Date 12 | 13 | docker image build --no-cache --network none --platform linux -t $imageName . 14 | if ($lastexitcode -ne 0) { exit 1 } 15 | 16 | $end = Get-Date 17 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 18 | Write-Output "RT_BENCHMARK_RESULT: $diff" 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/016_15_layers/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | # FROM alpine counts as one layer 3 | RUN dd if=/dev/urandom of=file-01 bs=8 count=1 4 | RUN dd if=/dev/urandom of=file-02 bs=8 count=1 5 | RUN dd if=/dev/urandom of=file-03 bs=8 count=1 6 | RUN dd if=/dev/urandom of=file-04 bs=8 count=1 7 | 8 | RUN dd if=/dev/urandom of=file-05 bs=8 count=1 9 | RUN dd if=/dev/urandom of=file-06 bs=8 count=1 10 | RUN dd if=/dev/urandom of=file-07 bs=8 count=1 11 | RUN dd if=/dev/urandom of=file-08 bs=8 count=1 12 | RUN dd if=/dev/urandom of=file-09 bs=8 count=1 13 | 14 | RUN dd if=/dev/urandom of=file-10 bs=8 count=1 15 | RUN dd if=/dev/urandom of=file-11 bs=8 count=1 16 | RUN dd if=/dev/urandom of=file-12 bs=8 count=1 17 | RUN dd if=/dev/urandom of=file-13 bs=8 count=1 18 | RUN dd if=/dev/urandom of=file-14 bs=8 count=1 19 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/016_15_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Build an image with fifteen layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | 11 | $start = Get-Date 12 | 13 | docker image build --no-cache --network none --platform linux -t $imageName . 14 | if ($lastexitcode -ne 0) { exit 1 } 15 | 16 | $end = Get-Date 17 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 18 | Write-Output "RT_BENCHMARK_RESULT: $diff" 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/018_20_layers/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 2 | # FROM alpine counts as one layer 3 | RUN dd if=/dev/urandom of=file-01 bs=8 count=1 4 | RUN dd if=/dev/urandom of=file-02 bs=8 count=1 5 | RUN dd if=/dev/urandom of=file-03 bs=8 count=1 6 | RUN dd if=/dev/urandom of=file-04 bs=8 count=1 7 | 8 | RUN dd if=/dev/urandom of=file-05 bs=8 count=1 9 | RUN dd if=/dev/urandom of=file-06 bs=8 count=1 10 | RUN dd if=/dev/urandom of=file-07 bs=8 count=1 11 | RUN dd if=/dev/urandom of=file-08 bs=8 count=1 12 | RUN dd if=/dev/urandom of=file-09 bs=8 count=1 13 | 14 | RUN dd if=/dev/urandom of=file-10 bs=8 count=1 15 | RUN dd if=/dev/urandom of=file-11 bs=8 count=1 16 | RUN dd if=/dev/urandom of=file-12 bs=8 count=1 17 | RUN dd if=/dev/urandom of=file-13 bs=8 count=1 18 | RUN dd if=/dev/urandom of=file-14 bs=8 count=1 19 | 20 | RUN dd if=/dev/urandom of=file-15 bs=8 count=1 21 | RUN dd if=/dev/urandom of=file-16 bs=8 count=1 22 | RUN dd if=/dev/urandom of=file-17 bs=8 count=1 23 | RUN dd if=/dev/urandom of=file-18 bs=8 count=1 24 | RUN dd if=/dev/urandom of=file-19 bs=8 count=1 25 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/018_20_layers/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Build an image with twenty layers 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $imageName = $env:RT_TEST_NAME 10 | 11 | $start = Get-Date 12 | 13 | docker image build --no-cache --network none --platform linux -t $imageName . 14 | if ($lastexitcode -ne 0) { exit 1 } 15 | 16 | $end = Get-Date 17 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 18 | Write-Output "RT_BENCHMARK_RESULT: $diff" 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /tests/cases/900_perf/010_image/020_build/group.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Linux Containers on Windows (LCOW) tests 2 | # LABELS: 3 | # NAME: lcow 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $res = 0 10 | 11 | function GroupInit([REF]$res) { 12 | # make sure alpine is pulled 13 | docker image pull --platform linux alpine:3.7 14 | 15 | $res.Value = 0 16 | } 17 | 18 | function GroupDeinit([REF]$res) { 19 | $res.Value = 0 20 | } 21 | 22 | $CMD=$args[0] 23 | Switch ($CMD) { 24 | 'init' { GroupInit([REF]$res) } 25 | 'deinit' { GroupDeinit([REF]$res) } 26 | } 27 | 28 | exit $res 29 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/010_dd/010_200MB_1KB_blocks/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a 200MB file on shared volume with 1KB writes 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | $blockSize = 1024 18 | $dataSizeMB = 200 19 | $dataSize = $dataSizeMB * 1024 * 1024 20 | $count = $dataSize / $blockSize 21 | 22 | $start = Get-Date 23 | 24 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 ` 25 | sh -c "dd if=/dev/zero of=/test/$fileName bs=$blockSize count=$count" 26 | if ($lastexitcode -ne 0) { exit 1 } 27 | 28 | $end = Get-Date 29 | $diff = ($end - $start).TotalSeconds 30 | $res = ($dataSizeMB / $diff).ToString("#.## MB/s") 31 | Write-Output "RT_BENCHMARK_RESULT: $res" 32 | 33 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 34 | exit $ret 35 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/010_dd/012_200MB_4KB_blocks/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a 200MB file on shared volume with 4KB writes 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | $blockSize = 4096 18 | $dataSizeMB = 200 19 | $dataSize = $dataSizeMB * 1024 * 1024 20 | $count = $dataSize / $blockSize 21 | 22 | $start = Get-Date 23 | 24 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 ` 25 | sh -c "dd if=/dev/zero of=/test/$fileName bs=$blockSize count=$count" 26 | if ($lastexitcode -ne 0) { exit 1 } 27 | 28 | $end = Get-Date 29 | $diff = ($end - $start).TotalSeconds 30 | $res = ($dataSizeMB / $diff).ToString("#.## MB/s") 31 | Write-Output "RT_BENCHMARK_RESULT: $res" 32 | 33 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 34 | exit $ret 35 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/010_dd/014_200MB_16KB_blocks/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a 200MB file on shared volume with 16KB writes 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | $blockSize = 16 * 1024 18 | $dataSizeMB = 200 19 | $dataSize = $dataSizeMB * 1024 * 1024 20 | $count = $dataSize / $blockSize 21 | 22 | $start = Get-Date 23 | 24 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 ` 25 | sh -c "dd if=/dev/zero of=/test/$fileName bs=$blockSize count=$count" 26 | if ($lastexitcode -ne 0) { exit 1 } 27 | 28 | $end = Get-Date 29 | $diff = ($end - $start).TotalSeconds 30 | $res = ($dataSizeMB / $diff).ToString("#.## MB/s") 31 | Write-Output "RT_BENCHMARK_RESULT: $res" 32 | 33 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 34 | exit $ret 35 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/010_dd/016_200MB_64KB_blocks/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a 200MB file on shared volume with 64KB writes 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | $blockSize = 64 * 1024 18 | $dataSizeMB = 200 19 | $dataSize = $dataSizeMB * 1024 * 1024 20 | $count = $dataSize / $blockSize 21 | 22 | $start = Get-Date 23 | 24 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 ` 25 | sh -c "dd if=/dev/zero of=/test/$fileName bs=$blockSize count=$count" 26 | if ($lastexitcode -ne 0) { exit 1 } 27 | 28 | $end = Get-Date 29 | $diff = ($end - $start).TotalSeconds 30 | $res = ($dataSizeMB / $diff).ToString("#.## MB/s") 31 | Write-Output "RT_BENCHMARK_RESULT: $res" 32 | 33 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 34 | exit $ret 35 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/010_dd/018_200MB_1MB_blocks/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a 200MB file on shared volume with 1MB writes 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | $blockSize = 1024 * 1024 18 | $dataSizeMB = 200 19 | $dataSize = $dataSizeMB * 1024 * 1024 20 | $count = $dataSize / $blockSize 21 | 22 | $start = Get-Date 23 | 24 | docker container run --platform linux --rm -v $env:TEST_TMP`:/test alpine:3.7 ` 25 | sh -c "dd if=/dev/zero of=/test/$fileName bs=$blockSize count=$count" 26 | if ($lastexitcode -ne 0) { exit 1 } 27 | 28 | $end = Get-Date 29 | $diff = ($end - $start).TotalSeconds 30 | $res = ($dataSizeMB / $diff).ToString("#.## MB/s") 31 | Write-Output "RT_BENCHMARK_RESULT: $res" 32 | 33 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 34 | exit $ret 35 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/010_dd/020_100MB_4KB_blocks_parallel/dd_5_parallel.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ret=0 4 | 5 | path=$1 6 | bs=$2 7 | count=$3 8 | 9 | dd if=/dev/zero of="$path"/file0 bs="$bs" count="$count" & 10 | pid0=$! 11 | 12 | dd if=/dev/zero of="$path"/file1 bs="$bs" count="$count" & 13 | pid1=$! 14 | 15 | dd if=/dev/zero of="$path"/file2 bs="$bs" count="$count" & 16 | pid2=$! 17 | 18 | dd if=/dev/zero of="$path"/file3 bs="$bs" count="$count" & 19 | pid3=$! 20 | 21 | dd if=/dev/zero of="$path"/file4 bs="$bs" count="$count" & 22 | pid4=$! 23 | 24 | wait $pid0 || ret=1 25 | wait $pid1 || ret=1 26 | wait $pid2 || ret=1 27 | wait $pid3 || ret=1 28 | wait $pid4 || ret=1 29 | 30 | exit $ret 31 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/010_dd/020_100MB_4KB_blocks_parallel/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create a 5 100MB files in parallel on shared volume with 4KB writes 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $fileName = "foobar" 12 | $testPath = Join-Path -Path $env:TEST_TMP -ChildPath $fileName 13 | 14 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 15 | New-Item -ItemType Directory -Force -Path $env:TEST_TMP 16 | 17 | $blockSize = 4096 18 | $dataSizeMB = 100 19 | $dataSize = $dataSizeMB * 1024 * 1024 20 | $count = $dataSize / $blockSize 21 | 22 | $start = Get-Date 23 | 24 | $p = [string]$pwd.Path 25 | docker container run --platform linux --rm ` 26 | -v $env:TEST_TMP`:/test ` 27 | -v $p`:/script ` 28 | alpine:3.7 sh /script/dd_5_parallel.sh /test $blockSize $count 29 | if ($lastexitcode -ne 0) { exit 1 } 30 | 31 | $end = Get-Date 32 | $diff = ($end - $start).TotalSeconds 33 | $res = (5 * $dataSizeMB / $diff).ToString("#.## MB/s") 34 | Write-Output "RT_BENCHMARK_RESULT: $res" 35 | 36 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $env:TEST_TMP 37 | exit $ret 38 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/010_stat_5000_files/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | DIR=$1 6 | 7 | # find calls lstat() 8 | find "$DIR" -type f > dev/null 9 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/010_stat_5000_files/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Stat 5000 files in a single directory created on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | $i = 0 15 | While ($i -lt 5000) { 16 | $fileName = "file-stat-" + $i 17 | $filePath = Join-Path -Path $testPath -ChildPath $fileName 18 | New-Item -ItemType File -Path $filePath 19 | $i += 1 20 | } 21 | 22 | $start = Get-Date 23 | 24 | $p = [string]$pwd.Path 25 | docker container run --platform linux --rm ` 26 | -v $testPath`:/test ` 27 | -v $p`:/script ` 28 | alpine:3.7 sh /script/run.sh /test 29 | if ($lastexitcode -ne 0) { $ret = 1 } 30 | 31 | $end = Get-Date 32 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 33 | Write-Output "RT_BENCHMARK_RESULT: $diff" 34 | 35 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 36 | 37 | exit $ret 38 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/015_stat_5000_non_existing_files/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # set -e 4 | # don't set -x as it creates a lot of noise 5 | 6 | DIR=$1 7 | 8 | for i in $(seq 5000); do 9 | stat "$DIR/file-$i" 2> /dev/null 10 | done 11 | exit 0 12 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/015_stat_5000_non_existing_files/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Stat 5000 non-existing files in a single directory on a shared volume 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | 15 | $start = Get-Date 16 | 17 | $p = [string]$pwd.Path 18 | docker container run --platform linux --rm ` 19 | -v $testPath`:/test ` 20 | -v $p`:/script ` 21 | alpine:3.7 sh /script/run.sh /test 22 | if ($lastexitcode -ne 0) { $ret = 1 } 23 | 24 | $end = Get-Date 25 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 26 | Write-Output "RT_BENCHMARK_RESULT: $diff" 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/020_touch_5000_files/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | # don't set -x as it creates a lot of noise 5 | 6 | DIR=$1 7 | 8 | for i in $(seq 5000); do 9 | touch "$DIR/file-$i" 10 | done 11 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/020_touch_5000_files/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create 5000 files in a single directory on a shared volume 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | 15 | $start = Get-Date 16 | 17 | $p = [string]$pwd.Path 18 | docker container run --platform linux --rm ` 19 | -v $testPath`:/test ` 20 | -v $p`:/script ` 21 | alpine:3.7 sh /script/run.sh /test 22 | if ($lastexitcode -ne 0) { $ret = 1 } 23 | 24 | $end = Get-Date 25 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 26 | Write-Output "RT_BENCHMARK_RESULT: $diff" 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/030_touch_stat_5000_files/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | # don't set -x as it creates a lot of noise 5 | 6 | DIR=$1 7 | 8 | for i in $(seq 5000); do 9 | touch "$DIR/file-$i" 10 | done 11 | 12 | # find calls lstat() 13 | find "$DIR" -type f > dev/null 14 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/030_touch_stat_5000_files/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Create 5000 files in a single directory on a shared volume and then stat them 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | 15 | $start = Get-Date 16 | 17 | $p = [string]$pwd.Path 18 | docker container run --platform linux --rm ` 19 | -v $testPath`:/test ` 20 | -v $p`:/script ` 21 | alpine:3.7 sh /script/run.sh /test 22 | if ($lastexitcode -ne 0) { $ret = 1 } 23 | 24 | $end = Get-Date 25 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 26 | Write-Output "RT_BENCHMARK_RESULT: $diff" 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/040_stat_touch_5000_files/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | # don't set -x as it creates a lot of noise 5 | 6 | DIR=$1 7 | 8 | # find calls lstat() 9 | find "$DIR" -type f -print0 | xargs -0 touch > dev/null 10 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/040_stat_touch_5000_files/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Stat and then touch 5000 files in a single directory created on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | $i = 0 15 | While ($i -lt 5000) { 16 | $fileName = "file-stat-" + $i 17 | $filePath = Join-Path -Path $testPath -ChildPath $fileName 18 | New-Item -ItemType File -Path $filePath 19 | $i += 1 20 | } 21 | 22 | $start = Get-Date 23 | 24 | $p = [string]$pwd.Path 25 | docker container run --platform linux --rm ` 26 | -v $testPath`:/test ` 27 | -v $p`:/script ` 28 | alpine:3.7 sh /script/run.sh /test 29 | if ($lastexitcode -ne 0) { $ret = 1 } 30 | 31 | $end = Get-Date 32 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 33 | Write-Output "RT_BENCHMARK_RESULT: $diff" 34 | 35 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 36 | 37 | exit $ret 38 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/050_stat_touch_stat_5000_files/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | DIR=$1 6 | 7 | # find calls lstat() 8 | find "$DIR" -type f -print0 | xargs -0 touch > dev/null 9 | find "$DIR" -type f > dev/null 10 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/050_stat_touch_stat_5000_files/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Stat, touch and then stat again 5000 files on a shared volume 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | $i = 0 15 | While ($i -lt 5000) { 16 | $fileName = "file-stat-" + $i 17 | $filePath = Join-Path -Path $testPath -ChildPath $fileName 18 | New-Item -ItemType File -Path $filePath 19 | $i += 1 20 | } 21 | 22 | $start = Get-Date 23 | 24 | $p = [string]$pwd.Path 25 | docker container run --platform linux --rm ` 26 | -v $testPath`:/test ` 27 | -v $p`:/script ` 28 | alpine:3.7 sh /script/run.sh /test 29 | if ($lastexitcode -ne 0) { $ret = 1 } 30 | 31 | $end = Get-Date 32 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 33 | Write-Output "RT_BENCHMARK_RESULT: $diff" 34 | 35 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 36 | 37 | exit $ret 38 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/060_write_5000_files_512B/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | DIR=$1 6 | SIZE=$2 7 | 8 | for i in $(seq 5000); do 9 | dd if=/dev/zero of="$DIR/file-$i" bs="$SIZE" count=1 10 | done 11 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/060_write_5000_files_512B/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Write 5000 small files in a single directory 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | 15 | $start = Get-Date 16 | 17 | $p = [string]$pwd.Path 18 | docker container run --platform linux --rm ` 19 | -v $testPath`:/test ` 20 | -v $p`:/script ` 21 | alpine:3.7 sh /script/run.sh /test 512 22 | if ($lastexitcode -ne 0) { $ret = 1 } 23 | 24 | $end = Get-Date 25 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 26 | Write-Output "RT_BENCHMARK_RESULT: $diff" 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 29 | exit $ret 30 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/065_write_write_5000_files_512B/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | DIR=$1 6 | SIZE=$2 7 | 8 | for i in $(seq 5000); do 9 | dd if=/dev/zero of="$DIR/file-$i" bs="$SIZE" count=1 10 | done 11 | 12 | for i in $(seq 5000); do 13 | dd if=/dev/zero of="$DIR/file-$i" bs="$SIZE" count=1 14 | done 15 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/065_write_write_5000_files_512B/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Write twice over the 5000 small files in a single directory 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | 15 | $start = Get-Date 16 | 17 | $p = [string]$pwd.Path 18 | docker container run --platform linux --rm ` 19 | -v $testPath`:/test ` 20 | -v $p`:/script ` 21 | alpine:3.7 sh /script/run.sh /test 512 22 | if ($lastexitcode -ne 0) { $ret = 1 } 23 | 24 | $end = Get-Date 25 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 26 | Write-Output "RT_BENCHMARK_RESULT: $diff" 27 | 28 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 29 | 30 | exit $ret 31 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/070_stat_read_5000_files_512B/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | # don't set -x as it creates a lot of noise 5 | 6 | DIR=$1 7 | 8 | # find calls lstat() 9 | find "$DIR" -type f -print0 | xargs -0 cat > dev/null 10 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/070_stat_read_5000_files_512B/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Stat and then read 5000 files in a single directory created on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | $i = 0 15 | While ($i -lt 5000) { 16 | $fileName = "test-" + $i 17 | $filePath = Join-Path -Path $testPath -ChildPath $fileName 18 | $f = new-object System.IO.FileStream $filePath, Create, ReadWrite 19 | $f.SetLength(512) 20 | $f.Close() 21 | $i += 1 22 | } 23 | 24 | $start = Get-Date 25 | 26 | $p = [string]$pwd.Path 27 | docker container run --platform linux --rm ` 28 | -v $testPath`:/test ` 29 | -v $p`:/script ` 30 | alpine:3.7 sh /script/run.sh /test 31 | if ($lastexitcode -ne 0) { $ret = 1 } 32 | 33 | $end = Get-Date 34 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 35 | Write-Output "RT_BENCHMARK_RESULT: $diff" 36 | 37 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 38 | 39 | exit $ret 40 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/075_stat_read_stat_read_5000_files_512B/run.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | DIR=$1 6 | 7 | # find calls lstat() 8 | find "$DIR" -type f -print0 | xargs -0 cat > dev/null 9 | find "$DIR" -type f -print0 | xargs -0 cat > dev/null 10 | -------------------------------------------------------------------------------- /tests/cases/900_perf/100_hostvol/020_single_dir/075_stat_read_stat_read_5000_files_512B/test.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Stat, read, stat, read 5000 files in a single directory created on the host 2 | # LABELS: 3 | # REPEAT: 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $ret = 0 10 | 11 | $testPath = $env:TEST_TMP 12 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 13 | New-Item -ItemType Directory -Force -Path $testPath 14 | $i = 0 15 | While ($i -lt 5000) { 16 | $fileName = "test-" + $i 17 | $filePath = Join-Path -Path $testPath -ChildPath $fileName 18 | $f = new-object System.IO.FileStream $filePath, Create, ReadWrite 19 | $f.SetLength(512) 20 | $f.Close() 21 | $i += 1 22 | } 23 | 24 | $start = Get-Date 25 | 26 | $p = [string]$pwd.Path 27 | docker container run --platform linux --rm ` 28 | -v $testPath`:/test ` 29 | -v $p`:/script ` 30 | alpine:3.7 sh /script/run.sh /test 31 | if ($lastexitcode -ne 0) { $ret = 1 } 32 | 33 | $end = Get-Date 34 | $diff = (($end - $start).TotalSeconds).ToString("#.##s") 35 | Write-Output "RT_BENCHMARK_RESULT: $diff" 36 | 37 | Remove-Item -Force -Recurse -ErrorAction Ignore -Path $testPath 38 | 39 | exit $ret 40 | -------------------------------------------------------------------------------- /tests/cases/_lib/lib.ps1: -------------------------------------------------------------------------------- 1 | 2 | # Turn on tracing 3 | Set-PSDebug -Trace 2 4 | 5 | # Temporary directories 6 | # TEST_TMP_ROOT: Root for all temporary directories/files 7 | # TEST_TMP: Per test temporary directory 8 | $env:TEST_TMP_ROOT = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _tmp 9 | $env:TEST_TMP = Join-Path -Path $env:TEST_TMP_ROOT -ChildPath $env:RT_TEST_NAME 10 | -------------------------------------------------------------------------------- /tests/cases/group.ps1: -------------------------------------------------------------------------------- 1 | # SUMMARY: Linux Containers on Windows (LCOW) tests 2 | # LABELS: 3 | # NAME: lcow 4 | 5 | $libBase = Join-Path -Path $env:RT_PROJECT_ROOT -ChildPath _lib 6 | $lib = Join-Path -Path $libBase -ChildPath lib.ps1 7 | . $lib 8 | 9 | $res = 0 10 | 11 | function GroupInit([REF]$res) { 12 | Write-Output "Environment" 13 | Get-ChildItem Env: 14 | $res.Value = 0 15 | } 16 | 17 | function GroupDeinit([REF]$res) { 18 | $res.Value = 0 19 | } 20 | 21 | $CMD=$args[0] 22 | Switch ($CMD) { 23 | 'init' { GroupInit([REF]$res) } 24 | 'deinit' { GroupDeinit([REF]$res) } 25 | } 26 | 27 | exit $res 28 | -------------------------------------------------------------------------------- /tests/scripts/Dockerfile.10layers: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 AS build 2 | RUN dd if=/dev/urandom of=file01 bs=128 count=1 3 | RUN dd if=/dev/urandom of=file02 bs=128 count=1 4 | RUN dd if=/dev/urandom of=file03 bs=128 count=1 5 | RUN dd if=/dev/urandom of=file04 bs=128 count=1 6 | RUN dd if=/dev/urandom of=file05 bs=128 count=1 7 | 8 | RUN dd if=/dev/urandom of=file06 bs=128 count=1 9 | RUN dd if=/dev/urandom of=file07 bs=128 count=1 10 | RUN dd if=/dev/urandom of=file08 bs=128 count=1 11 | RUN dd if=/dev/urandom of=file09 bs=128 count=1 12 | RUN dd if=/dev/urandom of=file10 bs=128 count=1 13 | 14 | FROM scratch 15 | COPY --from=build /file01 / 16 | COPY --from=build /file02 / 17 | COPY --from=build /file03 / 18 | COPY --from=build /file04 / 19 | COPY --from=build /file05 / 20 | 21 | COPY --from=build /file06 / 22 | COPY --from=build /file07 / 23 | COPY --from=build /file08 / 24 | COPY --from=build /file09 / 25 | COPY --from=build /file10 / 26 | -------------------------------------------------------------------------------- /tests/scripts/Dockerfile.15layers: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 AS build 2 | RUN dd if=/dev/urandom of=file01 bs=128 count=1 3 | RUN dd if=/dev/urandom of=file02 bs=128 count=1 4 | RUN dd if=/dev/urandom of=file03 bs=128 count=1 5 | RUN dd if=/dev/urandom of=file04 bs=128 count=1 6 | RUN dd if=/dev/urandom of=file05 bs=128 count=1 7 | 8 | RUN dd if=/dev/urandom of=file06 bs=128 count=1 9 | RUN dd if=/dev/urandom of=file07 bs=128 count=1 10 | RUN dd if=/dev/urandom of=file08 bs=128 count=1 11 | RUN dd if=/dev/urandom of=file09 bs=128 count=1 12 | RUN dd if=/dev/urandom of=file10 bs=128 count=1 13 | 14 | RUN dd if=/dev/urandom of=file11 bs=128 count=1 15 | RUN dd if=/dev/urandom of=file12 bs=128 count=1 16 | RUN dd if=/dev/urandom of=file13 bs=128 count=1 17 | RUN dd if=/dev/urandom of=file14 bs=128 count=1 18 | RUN dd if=/dev/urandom of=file15 bs=128 count=1 19 | 20 | FROM scratch 21 | COPY --from=build /file01 / 22 | COPY --from=build /file02 / 23 | COPY --from=build /file03 / 24 | COPY --from=build /file04 / 25 | COPY --from=build /file05 / 26 | 27 | COPY --from=build /file06 / 28 | COPY --from=build /file07 / 29 | COPY --from=build /file08 / 30 | COPY --from=build /file09 / 31 | COPY --from=build /file10 / 32 | 33 | COPY --from=build /file11 / 34 | COPY --from=build /file12 / 35 | COPY --from=build /file13 / 36 | COPY --from=build /file14 / 37 | COPY --from=build /file15 / 38 | -------------------------------------------------------------------------------- /tests/scripts/Dockerfile.1layer: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 AS build 2 | RUN dd if=/dev/urandom of=file1 bs=128 count=1 3 | 4 | FROM scratch 5 | COPY --from=build /file1 / 6 | -------------------------------------------------------------------------------- /tests/scripts/Dockerfile.20layers: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 AS build 2 | RUN dd if=/dev/urandom of=file01 bs=128 count=1 3 | RUN dd if=/dev/urandom of=file02 bs=128 count=1 4 | RUN dd if=/dev/urandom of=file03 bs=128 count=1 5 | RUN dd if=/dev/urandom of=file04 bs=128 count=1 6 | RUN dd if=/dev/urandom of=file05 bs=128 count=1 7 | 8 | RUN dd if=/dev/urandom of=file06 bs=128 count=1 9 | RUN dd if=/dev/urandom of=file07 bs=128 count=1 10 | RUN dd if=/dev/urandom of=file08 bs=128 count=1 11 | RUN dd if=/dev/urandom of=file09 bs=128 count=1 12 | RUN dd if=/dev/urandom of=file10 bs=128 count=1 13 | 14 | RUN dd if=/dev/urandom of=file11 bs=128 count=1 15 | RUN dd if=/dev/urandom of=file12 bs=128 count=1 16 | RUN dd if=/dev/urandom of=file13 bs=128 count=1 17 | RUN dd if=/dev/urandom of=file14 bs=128 count=1 18 | RUN dd if=/dev/urandom of=file15 bs=128 count=1 19 | 20 | RUN dd if=/dev/urandom of=file16 bs=128 count=1 21 | RUN dd if=/dev/urandom of=file17 bs=128 count=1 22 | RUN dd if=/dev/urandom of=file18 bs=128 count=1 23 | RUN dd if=/dev/urandom of=file19 bs=128 count=1 24 | RUN dd if=/dev/urandom of=file20 bs=128 count=1 25 | 26 | FROM scratch 27 | COPY --from=build /file01 / 28 | COPY --from=build /file02 / 29 | COPY --from=build /file03 / 30 | COPY --from=build /file04 / 31 | COPY --from=build /file05 / 32 | 33 | COPY --from=build /file06 / 34 | COPY --from=build /file07 / 35 | COPY --from=build /file08 / 36 | COPY --from=build /file09 / 37 | COPY --from=build /file10 / 38 | 39 | COPY --from=build /file11 / 40 | COPY --from=build /file12 / 41 | COPY --from=build /file13 / 42 | COPY --from=build /file14 / 43 | COPY --from=build /file15 / 44 | 45 | COPY --from=build /file16 / 46 | COPY --from=build /file17 / 47 | COPY --from=build /file18 / 48 | COPY --from=build /file19 / 49 | COPY --from=build /file20 / 50 | -------------------------------------------------------------------------------- /tests/scripts/Dockerfile.5layers: -------------------------------------------------------------------------------- 1 | FROM alpine:3.7 AS build 2 | RUN dd if=/dev/urandom of=file1 bs=128 count=1 3 | RUN dd if=/dev/urandom of=file2 bs=128 count=1 4 | RUN dd if=/dev/urandom of=file3 bs=128 count=1 5 | RUN dd if=/dev/urandom of=file4 bs=128 count=1 6 | RUN dd if=/dev/urandom of=file5 bs=128 count=1 7 | 8 | FROM scratch 9 | COPY --from=build /file1 / 10 | COPY --from=build /file2 / 11 | COPY --from=build /file3 / 12 | COPY --from=build /file4 / 13 | COPY --from=build /file5 / 14 | -------------------------------------------------------------------------------- /tests/scripts/generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -x 4 | set -e 5 | 6 | docker build --platform linux --no-cache \ 7 | -t linuxkit/test-lcow:1layer -f Dockerfile.1layer . 8 | docker push linuxkit/test-lcow:1layer 9 | 10 | docker build --platform linux --no-cache \ 11 | -t linuxkit/test-lcow:5layers -f Dockerfile.5layers . 12 | docker push linuxkit/test-lcow:5layers 13 | 14 | docker build --platform linux --no-cache \ 15 | -t linuxkit/test-lcow:10layers -f Dockerfile.10layers . 16 | docker push linuxkit/test-lcow:10layers 17 | 18 | docker build --platform linux --no-cache \ 19 | -t linuxkit/test-lcow:15layers -f Dockerfile.15layers . 20 | docker push linuxkit/test-lcow:15layers 21 | 22 | docker build --platform linux --no-cache \ 23 | -t linuxkit/test-lcow:20layers -f Dockerfile.20layers . 24 | docker push linuxkit/test-lcow:20layers 25 | --------------------------------------------------------------------------------