Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Add atomic CLI tests #273

Merged
merged 8 commits into from
Dec 4, 2017
Merged

Conversation

mike-nguyen
Copy link
Collaborator

This commit adds tests for the the atomic command. The tests revolve
mostly around pulling images and installing/running containers with
variations of the options in the atomic subcommand. These tests include:

  • Pull by fully qualified image name
  • Pull by short image name
  • Pull by fully qualified image name with --name option
  • Pull with tags
  • Pull by digest
  • Pull to ostree/docker storage
  • Images update command

Most of the tests use the cockpit container. This container was chosen
because it has most of the labels that the atomic command utilizes. For
simple tests, the busybox container was chosen because it is small.

@mike-nguyen
Copy link
Collaborator Author

centos will likely fail because of projectatomic/docker#285

- name: Remove specified image
command: atomic --debug --assumeyes images delete {{ image }}
- name: Remove {{ aid_image }}
command: atomic --assumeyes images delete {{ aid_image }} {{ del_options }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: no newline at the end of the file (GitHub actually highlights this in the diff!)


- name: Set cockpit container name for Fedora/CentOS
set_fact:
cockpit_cname: "registry.fedoraproject.org/f25/cockpit"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably should bump this to F26; F27 should be released Nov 14 and that will EOL F25

- role: atomic_run
ar_image: "{{ cockpit_cname }}"

- role: atomic_images_list_verify
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to keep checking that the cockpit image is still there after each operation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can drop this this check.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Still looks like there a bunch of extra image checks in the test. Could you audit the entire test and see if we really need each instance of atomic_images_list_verify?

- vars.yml

pre_tasks:
- name: Set cockpit container name for RHELAH
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe move these types of distro specific facts into vars files and use with_first_found to load them in?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ended up using vars_files with the ansible_distribution name since there was no difference between the different versions of a distribution (ie fedora 26, 27, etc). The only thing I had to account for the ansible_distribution for cahc which is centosdev. If needed I could use include_vars with with_first_found. I didn't feel that was needed for this simple case.

image_name: "{{ cockpit_short_name }}"
check_mode: false

- role: atomic_stop
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might want to drop a comment here to explain the json queries and what you are looking for.

apl_image: "{{ fq_name }}"
apl_options: "--storage=ostree"

# The TYPE field doesn't show up in the json output so
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a bug in atomic itself?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I forgot to file an upstream issue for that. I'll add a comment in the code with the issue: projectatomic/atomic#1129

@miabbott
Copy link
Collaborator

Excellent work overall! I like that you prefixed variable names in the roles to make them more unique per role (like we are supposed to do!)

I have a couple of minor comments, but I'm betting this can get merged very soon. Would like to kick it around myself, though

This commit adds tests for the the atomic command.  The tests revolve
mostly around pulling images and installing/running containers with
variations of the options in the atomic subcommand.  These tests include:

  - Pull by fully qualified image name
  - Pull by short image name
  - Pull by fully qualified image name with --name option
  - Pull with tags
  - Pull by digest
  - Pull to ostree/docker storage
  - Images update command

Most of the tests use the cockpit container.  This container was chosen
because it has most of the labels that the atomic command utilizes. For
simple tests, the busybox container was chosen because it is small.
@miabbott
Copy link
Collaborator

fedora/27/atomic failure looks like a Fedora manifestation of https://bugzilla.redhat.com/show_bug.cgi?id=1498575

The build of atomic in F27 is from Aug 24!!! Newer versions should have the fix for the problem observed.

- pull_tags

pre_tasks:
- name: Set cockpit container name for RHELAH
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this comment correct, i.e. only for RHELAH?

@miabbott
Copy link
Collaborator

Could we move the vars files under tests/atomic/vars/ rather than have them all in the root directory?

@mike-nguyen
Copy link
Collaborator Author

Could we move the vars files under tests/atomic/vars/ rather than have them all in the root directory?

Should be possible.

@mike-nguyen
Copy link
Collaborator Author

bot, retest this please


- name: Save JSON to variable
set_fact:
acl_json: "{{ acl.stdout | to_json | from_json }}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to use both filters? Seems like you should just be able to use from_json?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't need both. I'm not quite sure why I did that.


- name: Save JSON to variable
set_fact:
ail_json: "{{ ail.stdout | to_json | from_json }}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same question about both filters here

msg: "drmi_image is not defined"
when: drmi_image is undefined

- name: Set optioins
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/optioins/options/

- debug:
msg: "dt_img: {{ dt_image }}"

- debug:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you want to leave these debug: statements here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, removed!

@mike-nguyen
Copy link
Collaborator Author

New fixup with the comments addressed. I also snuck in a fix to handle the new TOML /etc/containers/registries.conf

replace: "[registries.insecure]\nregistries = ['{{ ansible_docker0.ipv4.address }}:5000']"
dest: /etc/containers/registries.conf
when: reg.stat.exists and toml.rc == 0

- name: add registeries
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/registeries/registries/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

register: toml
when: reg.stat.exists
ignore_errors: true

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I originally forgot to ignore errors on the grep so it failed when it wasn't a TOML file in the case of fedora/26/atomic. Fixed it here.

@mike-nguyen
Copy link
Collaborator Author

The CentOS failures are due to projectatomic/docker#285. CentOS won't use the fixed version of docker until projectatomic/docker#286 is fixed. The current version of docker on CentOS is using a version of docker that doesn't have a /etc/containers/registries.conf which causes the test to fail because the test uses an insecure registry. Once the docker fix is in CentOS the tests should pass.

@miabbott miabbott merged commit 31914d4 into projectatomic:master Dec 4, 2017
@mike-nguyen mike-nguyen deleted the atomic_tests branch March 28, 2018 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants