This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 470
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec/integration: added integration testing
This commit is the foundation for integration testing in the Portus repository. It uses docker containers to setup everything, and a lot of magic has been written around RSpec so it integrates with the style of the other tests. This commit does not handle on purpose the following (which have been submitted as separate issues): - Test multiple versions of Docker. - Test crono - Test portusctl - Cover as much of the registry client as possible - Add integration testing into CI Fixes #745 Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
- Loading branch information
Showing
12 changed files
with
775 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require "integration/helper" | ||
require "portus/registry_client" | ||
|
||
def push_test_images | ||
name = ldap? ? "johnldap" : "john" | ||
email = "john@example.com" | ||
password = "12341234" | ||
create_user(name, email, password, true) | ||
expect { login(name, password, email) }.not_to raise_error | ||
|
||
# Pulling images that we should already have (so we go faster :P). Then | ||
# re-tag it so they can be pushed. The re-tag has another name, to avoid | ||
# clashes with other tests. | ||
name = "registry" | ||
retag = "registre" | ||
pulled_tags = ["2.3.1", "2.4.0", "latest"] | ||
pulled_tags.each do |tag| | ||
base = "#{name}:#{tag}" | ||
tgt = "#{retag}:#{tag}" | ||
img = "library/#{base}" | ||
pull(img) | ||
system("docker tag #{img} #{registry_hostname}/#{tgt}") | ||
end | ||
|
||
expect(push("#{registry_hostname}/#{retag}")).to be_truthy | ||
|
||
# Wait until the registry has everything we need. | ||
eventually_expect(3) do | ||
tags = rails_exec("Tag.where(repository: Repository.find_by(name: '#{retag}')).to_json") | ||
tags.size | ||
end | ||
end | ||
|
||
integration "Client" do | ||
it "tells that a registry is reachable" do | ||
client = Portus::RegistryClient.new(registry_hostname) | ||
expect(client.reachable?).to be_truthy | ||
end | ||
|
||
it "fetches the catalog of pushed repositories" do | ||
push_test_images | ||
|
||
client = Portus::RegistryClient.new(registry_hostname) | ||
cat = client.catalog | ||
expected = { "registre" => ["2.3.1", "2.4.0", "latest"] } | ||
|
||
cat.each do |r| | ||
key = expected[r["name"]] | ||
next if key.nil? | ||
expect(key).to eq r["tags"] | ||
end | ||
end | ||
|
||
it "fetches the manifest of the given repo/tag" do | ||
push_test_images | ||
|
||
client = Portus::RegistryClient.new(registry_hostname) | ||
manifest = client.manifest("registre", "2.3.1") | ||
|
||
expect(manifest["name"]).to eq "registre" | ||
expect(manifest["tag"]).to eq "2.3" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 0.1 | ||
storage: | ||
filesystem: | ||
rootdirectory: /registry_data | ||
delete: | ||
enabled: true | ||
http: | ||
addr: 0.0.0.0:5000 | ||
debug: | ||
addr: 0.0.0.0:5001 | ||
auth: | ||
token: | ||
realm: http://<%= @ip %>:3000/v2/token | ||
service: <%= @ip %>:5000 | ||
issuer: <%= @ip %> | ||
rootcertbundle: /etc/docker/registry/portus.crt | ||
notifications: | ||
endpoints: | ||
- name: portus | ||
url: http://<%= @ip %>:3000/v2/webhooks/events | ||
timeout: 500ms | ||
threshold: 5 | ||
backoff: 1s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIFejCCA2ICAQEwDQYJKoZIhvcNAQEFBQAwgYIxCzAJBgNVBAYTAkRFMRAwDgYD | ||
VQQIDAdCYXZhcmlhMRMwEQYDVQQHDApOdWVyZW1iZXJnMQ0wCwYDVQQKDARTVVNF | ||
MRgwFgYDVQQDDA9wb3J0dXMudGVzdC5sYW4xIzAhBgkqhkiG9w0BCQEWFHJvb3RA | ||
cG9ydHVzLnRlc3QubGFuMB4XDTE1MDQxMjE1NTUwMloXDTI1MDQwOTE1NTUwMlow | ||
gYIxCzAJBgNVBAYTAkRFMRAwDgYDVQQIDAdCYXZhcmlhMRMwEQYDVQQHDApOdWVy | ||
ZW1iZXJnMQ0wCwYDVQQKDARTVVNFMRgwFgYDVQQDDA9wb3J0dXMudGVzdC5sYW4x | ||
IzAhBgkqhkiG9w0BCQEWFHJvb3RAcG9ydHVzLnRlc3QubGFuMIICIjANBgkqhkiG | ||
9w0BAQEFAAOCAg8AMIICCgKCAgEAyWA25/CoT+VsvCbwwx71KQ9YRy5gzadOufi3 | ||
2t4NpP8O27tbemc4coIsEDLRBJSXxhBv97mTvfjAU4/nO0tJDgEHlrpl+p5IA6Up | ||
3aYY2YqqY3riv+YI+e+RDcTau9Zd/ZxuB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