1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-06 12:45:57 +01:00
Commit Graph

72 Commits

Author SHA1 Message Date
Ruixin Bao
6e55cc8e6b unit: add unit test for rpm_host_install
A unit test for rm_add_files_to_host is added. The basic/expected
functionality of that function is tested by the new test

Other functions in rpm_host_install are mostly covered
by the integration test already, and thus not tested here

Closes: #1155
Approved by: giuseppe
2018-01-31 14:45:14 +00:00
Ruixin Bao
deb87057c5 unit: add unit test for refactored 'system_package' function
A 'high-level' unit test is added that covers basic functionality
check for refactored function '_handle_system_package_files'.

Closes: #1155
Approved by: giuseppe
2018-01-31 14:45:14 +00:00
Ruixin Bao
dfb54df58c syscontainer/unit: refactor writing info into a function
This commit refactors the writing info part from 'do_checkout'
into a function.

Also, because of the above action, two of the local variables
'installed_files_template' and 'rename_files' are also removed

Other than those, an extra error case was added to the except list.

A unit test is added for future regression

Closes: #1155
Approved by: giuseppe
2018-01-31 14:45:14 +00:00
Ruixin Bao
c25101e7db syscontainers/unit: refactor rename files part
This commit refactors the "rename file value substitution" code
section in '_do_checkout' function

There should not be any functional impact with this commit

A unit test is added for future regression

Closes: #1155
Approved by: giuseppe
2018-01-31 14:45:14 +00:00
Ruixin Bao
676ad7cb5f syscontainer: refactor tmpfile cleanup and manifest
This commit contains small refactoring of getting manifest
attributes and refactoring of the "tempfile cleaning during
upgrade" code section in '_do_checkout'

Also, 'has_container_service' local variable is genereated in the
function instead of being passed in as a parameter. This is done
because in the future refactoring we might want to elminate the
usage of local variables related to manifest completly.

A unit test is added to verify getting manifest attribute works
as expected

Closes: #1155
Approved by: giuseppe
2018-01-31 14:45:14 +00:00
Ruixin Bao
c41a3c55b2 syscontainers: refactoring duplicated write config function
This commit contains refactoring for write config in '_do_checkout' function,
this refactoring also removes the duplication of writing config in 'run_once'

There should not be functional impact with this commit.

A unit test is added for future regression

Closes: #1160
Approved by: giuseppe
2018-01-17 09:21:09 +00:00
Ruixin Bao
78340b47c7 syscontainers: refactor handling rootfs into a function
In _do_checkout, we refactor the part for getting rootfs location
into a function.

A todo comment( refactoring 'missing image layer check') is also added
in this commit based on discussions on irc

A unit test is added for future regression

Closes: #1154
Approved by: giuseppe
2018-01-04 15:35:16 +00:00
Ruixin Bao
340a172108 syscontainer: make '_get_remote_location' into static method
This is regression from https://github.com/projectatomic/atomic/pull/1152.

It appears that 'self' is no longer used when '_resolve_remote_path' is moved into
'_get_remote_location'. Thus, '_get_remote_location' is made to be static

Closes: #1154
Approved by: giuseppe
2018-01-04 15:35:16 +00:00
Ruixin Bao
64cc86e7ca syscontainer/unit: add test to test remote refactoring
Made a new class to track all the refactored functions' unit tests
(for future usage)

Added a unit test to test the functionality of the factored out
_get_remote_location function.

Closes: #1152
Approved by: giuseppe
2018-01-03 12:36:16 +00:00
Giuseppe Scrivano
25a5a15a31 util.py: add function for retrieving the known proc capabilities
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1119
Approved by: ashcrow
2017-10-26 13:38:40 +00:00
Steve Milner
3fb193345b test: Basic unittest for SystemContainers._get_skopeo_args
Signed-off-by: Steve Milner <smilner@redhat.com>

Closes: #1096
Approved by: giuseppe
2017-09-09 09:17:06 +00:00
Steve Milner
6e1aee7db8 tests: unit tests for system containers container_exec
Closes: #1075
Approved by: ashcrow
2017-08-29 07:11:54 +00:00
Steve Milner
ee5e246d7a test: Add test for atomic.conf validation
The atomic.conf file is now tested to validate it is valid YAML. The two
cases checked are:

- The file contents in it's shipped state
- The file contents with examples uncommented

An example has no space between the hash and the start of the example:

    #example: value

While a comment is expected to have a space:

    # I am a comment

Closes: #1009
Approved by: giuseppe
2017-06-29 08:11:14 +00:00
Brent Baude
3c0cbc69ea Incorporate registries parsing tool
Ideally atomic will be able to run multiple container
runtimes.  In and effort to do so, we must have a concept
of a global registries configuration file which will allow
us to pull images with atomic and skopeo. The tooling
that parses the global configuration file is:

https://github.com/projectatomic/registries

This is step one in the implementation of this tooling
and direction.

Closes: #1003
Approved by: rhatdan
2017-05-17 15:19:53 +00:00
Steve Milner
2760e30296 Atomic/util.py: Add no_proxy
http_proxy and https_proxy are currently supported in /etc/atomic.conf.
This change adds no_proxy support. no_proxy is for urls which should
not go through a proxy.

Closes: #999
Approved by: baude
2017-05-13 00:47:55 +00:00
Tomas Tomecek
805b955ed5 mount: create context manager for {Docker,OSTree}Mount
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>

Closes: #976
Approved by: rhatdan
2017-04-24 20:29:15 +00:00
Miloslav Trmač
20364af60a Fix “fqdn” computation in RegistryInspect
When the repo namespaces are unknown and the registry is docker.io, the
default value "library" should be used.

This matters when specifying library images in the shortest form, e.g.
"busybox:latest"; we would be fetching
docker://docker.io/busybox:latest instead of
docker://docker.io/library/busybox:latest.

skopeo would normalize that when fetching anyway, but this makes the output more
regular (which, in particular, matters for looking up
registries.d/*.yaml entries) and more consistent with the “fully
qualified domain(?) name” terminology.

Most importantly, the docker/distribution reference recorded inside the
signature should use the fully expanded form for maximum semantic
clarity.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #937
Approved by: baude
2017-04-13 22:40:09 +00:00
Brent Baude
12d674f26e util: Don't try to create directories at module import time
We shouldn't do anything at module import time, as that happens during builds,
where we don't want to touch the host system (and may not have privileges to do
so).

This required some refactoring of the locking code too, as simply
instantiating the decorator was creating files too.

Closes: https://github.com/projectatomic/atomic/issues/963

Closes: #966
Approved by: rhatdan
2017-04-13 19:29:39 +00:00
Brent Baude
1b216a4919 Atomic/install.py: Record installs for later use
When installing an image, we now write a small bit of json
to /var/lib/atomic/install.json.  The json format is:

{
	<image_name>: {
			     id: <image_id>,
			     install_date: <install_date_in_utc
			 }
}

This will be used in update, run, etc to ensure that any image
with an INSTALL label is first installed.

Closes: #950
Approved by: giuseppe
2017-03-28 19:10:57 +00:00
Giuseppe Scrivano
4cb0b1e7be syscontainers: change $ORIGIN: prefix
allow the $ORIGIN: prefix only when the branch is specified, otherwise it
is not decidable if $ORIGIN is the source to pull the image from or the
name of the image itself.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #767
Approved by: rhatdan
2017-03-22 13:27:53 +00:00
Giuseppe Scrivano
1348c3d29b tests: fix test_pull when run locally
I've observed some failures when running "make check", mock the function
to return something useful.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #893
Approved by: baude
2017-02-16 09:16:43 +00:00
Aaron Weitekamp
df95392e3b fix re module bug
Closes: #891
Approved by: rhatdan
2017-02-14 15:14:13 +00:00
Aaron Weitekamp
ae8e281137 add assumeyes to pull test
Closes: #853
Approved by: rhatdan
2017-02-06 22:41:40 +00:00
Aaron Weitekamp
ddc72a61e8 Inline pubkeys in policy.json
Closes: #853
Approved by: rhatdan
2017-02-06 22:41:40 +00:00
Brent Baude
048fced244 Fix Delete errors with images and containers
Fix a slew of issues related to deletion of images and containers.  Also
added --assume_yes to be consistent with other commands.  This will benefit
dbus interaction as well given that we do not want confirmation occuring
over dbus.

Issues that were fixed:
 * Proper catch and error for trying to delete all images|containers when no images|containers exist
 * Catch and error when no image|container is given by user and no --all
 * when --storage and --all are used, only images|containers in that backend are now deleted
 * when --all is given but not --storage, all images|containers from all backends are now deleted.
 * Fixed logical error when deleting containers
 * Deletion of images|containers now is consistent in its confirm and abort messages.

Added unittests.

Closes: #864
Approved by: rhatdan
2017-02-04 11:18:49 +00:00
Brent Baude
167986a809 Add pull by digest unittests
Added two tests for pull by digest: one where the image is not
present and the other when it is.

Also, addressed review comments.

Closes: #856
Approved by: baude
2017-02-01 20:02:00 +00:00
Brent Baude
edb87bfdea Fixup trust tests
There is a python bug that in 2.7.5 that is causing
the unittest failures on centos_atomic.  The bug
is related to how regex is compiled and used.

Adding a simple decorator to skip tests that fail
because of that in the trust tests.

Closes: #848
Approved by: baude
2017-01-25 21:15:34 +00:00
Brent Baude
add28f5b40 Leverage skopeo inspect and inspect --raw
Remove discovery code and use skopeo where possible.

Closes: #846
Approved by: jlebon
2017-01-23 19:00:24 +00:00
Brent Baude
c7aafb3314 Refactor Pull, Update, Install, Run
Refactor several of the atomic verbs and subverbs to take advantage
of object refactoring.

Also, do not pull images with skopeo if the local image is already
at the latest.

$ sudo python ./atomic --debug pull busybox
Namespace(_class=<class 'Atomic.pull.Pull'>, assumeyes=False, debug=True, func='pull_image', image='busybox', reg_type=None, storage='docker')
Latest version of busybox already present.

Closes: #825
Approved by: baude
2017-01-17 22:16:36 +00:00
Aaron Weitekamp
ef8b07ef79 update default trust policy file
Signed-off-by: Aaron Weitekamp <aweiteka@redhat.com>

Closes: #822
Approved by: rhatdan
2017-01-16 14:27:00 +00:00
Aaron Weitekamp
8df71d7c6a extend image URI validation
Closes: #819
Approved by: rhatdan
2017-01-10 15:49:28 +00:00
Aaron Weitekamp
6dfc3ccd87 Validate reg input to trust add cmd
Signed-off-by: Aaron Weitekamp <aweiteka@redhat.com>

Closes: #816
Approved by: rhatdan
2017-01-09 13:58:16 +00:00
Giuseppe Scrivano
610dfb178b images: apply filters before any output
otherwise we would not honor them for --json.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #803
Approved by: rhatdan
2016-12-21 14:39:46 +00:00
Brent Baude
e405c6a048 Refactor containers verb
With the exception of fstrim, the containers verb has now been
refactored.  It primarily now uses the containers object in its
implementation.

Closes: #792
Approved by: rhatdan
2016-12-09 14:05:49 +00:00
Brent Baude
dc30815599 Unify and refactor atomic verify
Using our refactoring model, verify is now streamlined. We no longer
compare base images as that is not currently possible for both
V1 and V2 schemas.

Verify will now always look at the release and version labels for
comparison.  Should those labels not exist, it will use the
manifest digest for ostree; and it will use the image IDs for
docker.

Closes: #785
Approved by: rhatdan
2016-12-07 15:18:22 +00:00
Brent Baude
c10c5f0b1a Atomic Info Unittests
Add unittests for ostree, docker backends for the version
sub-verb to images.

Closes: #774
Approved by: rhatdan
2016-11-30 17:11:24 +00:00
Brent Baude
ef984ed066 Refactor images
Covers all but verify and generate.  This is a refactoring of the
images subverbs (i.e. info, version, delete, ...)

Added in a unittest for list and info.

Closes: #771
Approved by: baude
2016-11-29 21:47:05 +00:00
Jonathan Lebon
75726671d8 test_util.py: adapt for newer sepolicies
In Fedora 25, the default container context changed to
'container_file_t'. Adapt the unit test accordingly.

Closes: #766
Approved by: rhatdan
2016-11-22 19:27:43 +00:00
Brent Baude
16c761447c backends: has image|container return objects
If the has_image|has_container evals to True, then return
the proper object; else None

Add unittest structure for backends/backendutils.py

We want to make sure we have a good backend/backendutils
unittest.  This should simplify unittests for all backends.

refactor.py: Remove the file used to help mini-test the
refactoring work.  It is not needed by upstream and was
only including during the development phases.

Closes: #757
Approved by: baude
2016-11-22 15:38:13 +00:00
Brent Baude
121435f1cc Use centos for all test images
To download less images, we now just used centos for the
base of all atomic-test images

Closes: #759
Approved by: rhatdan
2016-11-21 15:32:09 +00:00
Brent Baude
552e3f3bcb atomic diff: Add ability to compare metadata
With the -m switch, we can now compare the metadata between
the two diff objects.  We report only the differences between them. All
common data is deleted from the object structures.

This solves --> https://github.com/projectatomic/atomic/issues/760

Closes: #764
Approved by: baude
2016-11-18 21:22:51 +00:00
Dan Walsh
b110e73c88 Refactor Trust code to work with dbus interface
Closes: #723
Approved by: rhatdan
2016-10-24 21:39:23 +00:00
Aaron Weitekamp
6d909022fc trust show GPG key ID
Closes: #702
Approved by: rhatdan
2016-10-13 20:59:03 +00:00
Aaron Weitekamp
8d23c2bffa remove sigstore config with trust delete 2016-10-13 13:34:20 -04:00
Brent Baude
4aa4318c29 decompose: Add ability to decompose image w/digest
Adding the ability to decompose an input image "name" that
includes a digest. For example:

docker.io/library/fedora@sha256:64a02df6aac27d1200c2572fe4b9949f1970d05f74d367ce4af994ba5dc3669e

Also, reword the decompose method in a Decompose class.  This simplifies the use of
decomposition and allows for growth.

Example usage:
   registry, repo, image, tag, digest = Decompose("docker.io/library/busybox:latest").all
   repo = Decompose("docker.io/library/busybox:latest").repo
   digest = Decompose("docker.io/fedora@sha256:64a02df6aac27d1200c2...67ce4af994ba5dc3669e").digest

Closes: #701
Approved by: rhatdan
2016-10-13 12:23:37 +00:00
Brent Baude
adc8956f50 Allow pull from registry not in docker conf
We now allow pulls from registries that are not in
the docker configuration file.  This altered our
decompose method a bit.  We now check the registry
in decompose to see if it resolves on the network.
If so, then we use it.

Closes: #693
Approved by: baude
2016-10-11 13:23:58 +00:00
Brent Baude
aa59a5e285 Introduce registry inspect methods
Add two classes and several new methods for inspecting
registries and images.  These methods are helpful
for:

* taking user input (i.e. image names, partial image names) and determining
the fully qualified names.
* determining the fq name when the registry is omitted by the user.
* obtaining image manifests
* mimicing skopeo inspect

Closes: #687
Approved by: baude
2016-10-07 19:54:35 +00:00
Brent Baude
e83c2c5dd8 Atomic.util: More robust decompose
Colleagues asked for decompose to be improved to where it took
an image name and broke it into registry, repo, image, and tag.
It also should mimic docker's implementation where 'library' is a known
exception

Also added unittests for decompose.  Removed a singular glob  test
as it is no longer valid

Closes: #677
Approved by: rhatdan
2016-10-05 17:00:11 +00:00
Aaron Weitekamp
0870507325 add atomic trust show
Closes: #629
Approved by: rhatdan
2016-09-20 08:48:20 +00:00
Aaron Weitekamp
b66284fb81 refactor trust
Closes: #629
Approved by: rhatdan
2016-09-20 08:48:20 +00:00