From bc26eb978e2050c5136e67918c045b164d0648da Mon Sep 17 00:00:00 2001 From: James Oliver Date: Mon, 28 Mar 2016 22:09:56 -0700 Subject: [PATCH] Add template validation, fix categories --- integration/core/test_catalog.py | 60 +++++++++++++++++-- integration/requirements.txt | 5 +- kubernetes-templates/guestbook/config.yml | 2 +- kubernetes-templates/wordpress/config.yml | 2 +- swarm-templates/wordpress/config.yml | 2 +- templates/MongoDB/config.yml | 2 +- templates/alfresco/config.yml | 2 +- templates/droneworkers/0/rancher-compose.yml | 2 +- templates/droneworkers/config.yml | 2 +- .../elasticsearch-2/0/rancher-compose.yml | 2 +- templates/galera/config.yml | 2 +- templates/gocd-agent/config.yml | 2 +- templates/gocd-server/config.yml | 2 +- templates/janitor/config.yml | 2 +- templates/kafka/config.yml | 4 +- templates/minecraft/config.yml | 2 +- templates/nuxeo/0/rancher-compose.yml | 2 +- templates/nuxeo/config.yml | 2 +- templates/odoo/0/rancher-compose.yml | 2 +- .../0/docker-compose.yml | 0 .../0/rancher-compose.yml | 0 .../catalogIcon-rocket.chat.svg | 0 .../{rocket.chat => rocket-chat}/config.yml | 0 templates/taiga/0/rancher-compose.yml | 2 +- templates/wordpress/0/rancher-compose.yml | 2 +- templates/wordpress/config.yml | 2 +- templates/zookeeper/config.yml | 2 +- 27 files changed, 81 insertions(+), 28 deletions(-) rename templates/{rocket.chat => rocket-chat}/0/docker-compose.yml (100%) rename templates/{rocket.chat => rocket-chat}/0/rancher-compose.yml (100%) rename templates/{rocket.chat => rocket-chat}/catalogIcon-rocket.chat.svg (100%) rename templates/{rocket.chat => rocket-chat}/config.yml (100%) diff --git a/integration/core/test_catalog.py b/integration/core/test_catalog.py index 5a281ee..d89f116 100644 --- a/integration/core/test_catalog.py +++ b/integration/core/test_catalog.py @@ -3,6 +3,8 @@ import cattle import subprocess import sys import os +import re +# import yaml def _base(): @@ -49,12 +51,33 @@ def catalog_service(catalog_bin): return CatalogService(catalog_bin) -@pytest.fixture +@pytest.fixture(scope='session') def client(): url = 'http://localhost:8088/v1-catalog/schemas' return cattle.from_env(url=url) +@pytest.fixture(scope='session') +def templates(client): + templates = client.list_template() + assert len(templates) > 0 + return templates + + +@pytest.fixture(scope='session') +def requests(): + return requests.Session() + + +@pytest.fixture(scope='session') +def template_details(client, templates): + for template in templates: + template.versionDetails = {} + for version, link in template.versionLinks.iteritems(): + template.versionDetails[version] = client._get(link) + return templates + + def test_validate_exits_normal(catalog_service): catalog_service.assert_retcode( 0, '-catalogUrl', @@ -62,6 +85,35 @@ def test_validate_exits_normal(catalog_service): '-validate', '-port', '18088') -def test_catalog_list(client): - templates = client.list_template() - assert len(templates) > 0 +def test_stack_name(templates): + hostname_label = re.compile(r'^[a-zA-Z0-9\-]{1,63}$') + for template in templates: + # stack_name must be a valid hostname label + assert hostname_label.match(template.id.split(':')[-1].split('*')[-1]) + + +def test_maintainers(templates): + maintainer = re.compile(r'^([\S]+ ){2,5}<[^@]+@[^@]+\.[^@]+>$') + for template in templates: + # Maintainer will soon be a requirement + # assert template.maintainer + if template.maintainer: + assert maintainer.match(template.maintainer) + + +def test_versions(templates): + for template in templates: + # default version must be defined + assert template.defaultVersion + # template with default version must be defined + assert template.versionLinks[template.defaultVersion] + + +def test_template_questions(template_details): + for template in template_details: + for _, template in template.versionDetails.iteritems(): + # there must exist a rancher-compose.yml file + assert template.files['rancher-compose.yml'] + # rancherConfig = yaml.load(template.files['rancher-compose.yml']) + # there must exist at least one question + # assert len(rancherConfig['.catalog']['questions']) > 0 diff --git a/integration/requirements.txt b/integration/requirements.txt index afcbb44..b44c9dd 100644 --- a/integration/requirements.txt +++ b/integration/requirements.txt @@ -1,4 +1,5 @@ -cattle==0.5.1 +cattle==0.5.3 +pyyaml==3.11 flake8 -pytest==2.3.5 +pytest==2.8.7 diff --git a/kubernetes-templates/guestbook/config.yml b/kubernetes-templates/guestbook/config.yml index f58d23d..3a04030 100644 --- a/kubernetes-templates/guestbook/config.yml +++ b/kubernetes-templates/guestbook/config.yml @@ -1,4 +1,4 @@ name: "K8s Example Guestbook" description: "It's a guestbook" version: 1.0.0 -category: Test +category: Blogging diff --git a/kubernetes-templates/wordpress/config.yml b/kubernetes-templates/wordpress/config.yml index acfa707..711e606 100644 --- a/kubernetes-templates/wordpress/config.yml +++ b/kubernetes-templates/wordpress/config.yml @@ -1,4 +1,4 @@ name: "K8s Example WordPress" description: "Blogging platform" version: 1.0.0 -category: "Blog tool, publishing platform and CMS" +category: Blogging diff --git a/swarm-templates/wordpress/config.yml b/swarm-templates/wordpress/config.yml index b601df3..97e474d 100644 --- a/swarm-templates/wordpress/config.yml +++ b/swarm-templates/wordpress/config.yml @@ -2,4 +2,4 @@ name: Wordpress description: | Blog tool, publishing platform and CMS version: latest-rancher1 -category: Blog +category: Blogging diff --git a/templates/MongoDB/config.yml b/templates/MongoDB/config.yml index eacc787..46bd0e9 100644 --- a/templates/MongoDB/config.yml +++ b/templates/MongoDB/config.yml @@ -2,4 +2,4 @@ name: MongoDB description: | MongoDB Replica Set. version: 3.2-rancher1 -category: Database +category: Databases diff --git a/templates/alfresco/config.yml b/templates/alfresco/config.yml index 4750406..2b42485 100644 --- a/templates/alfresco/config.yml +++ b/templates/alfresco/config.yml @@ -1,5 +1,5 @@ name: Alfresco description: | - Slef hosted your EDM with Alfresco on few seconds. + An ECM and BPM platform. version: 5.1.0 category: EDM diff --git a/templates/droneworkers/0/rancher-compose.yml b/templates/droneworkers/0/rancher-compose.yml index 876717a..3f143db 100644 --- a/templates/droneworkers/0/rancher-compose.yml +++ b/templates/droneworkers/0/rancher-compose.yml @@ -1,6 +1,6 @@ .catalog: name: Drone Rancher Node Manager - version: 0.1.0-cloundautique1 + version: 0.1.0-cloudnautique1 description: | (Experimental) Poll Rancher Metadata for Drone Agents and add/remove nodes accordingly. diff --git a/templates/droneworkers/config.yml b/templates/droneworkers/config.yml index e02f13c..7b44956 100644 --- a/templates/droneworkers/config.yml +++ b/templates/droneworkers/config.yml @@ -2,5 +2,5 @@ name: Drone Rancher Node Manager description: | (Experimental) Dynamically add remove Drone worker nodes version: 0.1.0-cloudnautique1 -category: "Continuous Integration" +category: Continuous Integration minimum_rancher_version: v0.56.0 diff --git a/templates/elasticsearch-2/0/rancher-compose.yml b/templates/elasticsearch-2/0/rancher-compose.yml index c10b9ed..e4fe63a 100644 --- a/templates/elasticsearch-2/0/rancher-compose.yml +++ b/templates/elasticsearch-2/0/rancher-compose.yml @@ -1,6 +1,6 @@ .catalog: name: "Elasticsearch" - version: "2.2.1-rancher1" + version: "2.2.2-rancher1" description: "Elasticsearch. You know, for search" questions: - variable: cluster_name diff --git a/templates/galera/config.yml b/templates/galera/config.yml index 340ce73..7fdfba3 100644 --- a/templates/galera/config.yml +++ b/templates/galera/config.yml @@ -2,4 +2,4 @@ name: MariaDB Galera Cluster description: | (Experimental) Synchronous multi-master cluster for MariaDB version: 10.0.22-rancher1 -category: Database +category: Databases diff --git a/templates/gocd-agent/config.yml b/templates/gocd-agent/config.yml index 44fa3c7..165f3b7 100644 --- a/templates/gocd-agent/config.yml +++ b/templates/gocd-agent/config.yml @@ -2,7 +2,7 @@ name: gocd-agent description: | (Experimental) Gocd agent version: 16.2.1-rancher1 -category: "Continuous Integration" +category: Continuous Integration maintainer: "Raul Sanchez " minimum_rancher_version: v0.59.0 license: diff --git a/templates/gocd-server/config.yml b/templates/gocd-server/config.yml index ebc6ca8..a87f980 100644 --- a/templates/gocd-server/config.yml +++ b/templates/gocd-server/config.yml @@ -2,7 +2,7 @@ name: gocd-server description: | (Experimental) Gocd server version: 16.2.1-rancher1 -category: "Continuous Integration" +category: Continuous Integration maintainer: "Raul Sanchez " minimum_rancher_version: v0.59.0 license: diff --git a/templates/janitor/config.yml b/templates/janitor/config.yml index 75a4e26..ec38060 100644 --- a/templates/janitor/config.yml +++ b/templates/janitor/config.yml @@ -2,6 +2,6 @@ name: Janitor description: | Automatic cleanup of unused images on hosts, in order to save disk space. version: v1.5.2 -category: monitoring +category: Monitoring maintainer: Steve Shipway diff --git a/templates/kafka/config.yml b/templates/kafka/config.yml index ab7404a..c93f189 100644 --- a/templates/kafka/config.yml +++ b/templates/kafka/config.yml @@ -1,8 +1,8 @@ name: Apache Kafka description: | (Experimental) Kafka cluster -version: 0.8.2-rancher1 -category: clustering +version: 0.9.0-rancher1 +category: Clustering maintainer: "Raul Sanchez " minimum_rancher_version: v0.56.0 license: diff --git a/templates/minecraft/config.yml b/templates/minecraft/config.yml index f106ac5..7cfaffd 100644 --- a/templates/minecraft/config.yml +++ b/templates/minecraft/config.yml @@ -2,5 +2,5 @@ name: Minecraft description: | Multiplayer block game for wasting lots of time version: v1.8 -category: entertainment +category: Entertainment maintainer: Steve Shipway diff --git a/templates/nuxeo/0/rancher-compose.yml b/templates/nuxeo/0/rancher-compose.yml index b440f0a..753fd4b 100644 --- a/templates/nuxeo/0/rancher-compose.yml +++ b/templates/nuxeo/0/rancher-compose.yml @@ -1,6 +1,6 @@ .catalog: name: "Nuxeo Platform" - version: "rancher-1.0" + version: 8.1-rancher1 description: | Enterprise Content Management Platform for Business Applications diff --git a/templates/nuxeo/config.yml b/templates/nuxeo/config.yml index 1077e5d..2b9b4d3 100644 --- a/templates/nuxeo/config.yml +++ b/templates/nuxeo/config.yml @@ -2,5 +2,5 @@ name: Nuxeo Platform description: | Enterprise Content Management Platform for Business Applications -version: 8.1 +version: 8.1-rancher1 category: ECM diff --git a/templates/odoo/0/rancher-compose.yml b/templates/odoo/0/rancher-compose.yml index d630867..1f0f6a0 100644 --- a/templates/odoo/0/rancher-compose.yml +++ b/templates/odoo/0/rancher-compose.yml @@ -1,6 +1,6 @@ .catalog: name: "Odoo" - version: "0.1-educaas" + version: v0.1-educaas description: "ERP management powered by Odoo" uuid: odoo-0 questions: diff --git a/templates/rocket.chat/0/docker-compose.yml b/templates/rocket-chat/0/docker-compose.yml similarity index 100% rename from templates/rocket.chat/0/docker-compose.yml rename to templates/rocket-chat/0/docker-compose.yml diff --git a/templates/rocket.chat/0/rancher-compose.yml b/templates/rocket-chat/0/rancher-compose.yml similarity index 100% rename from templates/rocket.chat/0/rancher-compose.yml rename to templates/rocket-chat/0/rancher-compose.yml diff --git a/templates/rocket.chat/catalogIcon-rocket.chat.svg b/templates/rocket-chat/catalogIcon-rocket.chat.svg similarity index 100% rename from templates/rocket.chat/catalogIcon-rocket.chat.svg rename to templates/rocket-chat/catalogIcon-rocket.chat.svg diff --git a/templates/rocket.chat/config.yml b/templates/rocket-chat/config.yml similarity index 100% rename from templates/rocket.chat/config.yml rename to templates/rocket-chat/config.yml diff --git a/templates/taiga/0/rancher-compose.yml b/templates/taiga/0/rancher-compose.yml index 8fa4baf..b504209 100644 --- a/templates/taiga/0/rancher-compose.yml +++ b/templates/taiga/0/rancher-compose.yml @@ -1,6 +1,6 @@ .catalog: name: "Taiga" - version: "v0.1-educaas" + version: "v0.1-educaas1" description: "Project management platform for agile developers" uuid: taiga-0 minimum_rancher_version: v0.51.0 diff --git a/templates/wordpress/0/rancher-compose.yml b/templates/wordpress/0/rancher-compose.yml index e45674a..4b7075e 100644 --- a/templates/wordpress/0/rancher-compose.yml +++ b/templates/wordpress/0/rancher-compose.yml @@ -1,6 +1,6 @@ .catalog: name: "Wordpress" - version: "v0.1-educaas" + version: "v0.1-educaas1" description: "Blog tool, publishing platform and CMS" uuid: Wordpress-0 minimum_rancher_version: v0.51.0 diff --git a/templates/wordpress/config.yml b/templates/wordpress/config.yml index d92812a..5f43d8b 100644 --- a/templates/wordpress/config.yml +++ b/templates/wordpress/config.yml @@ -2,4 +2,4 @@ name: Wordpress description: | Blog tool, publishing platform and CMS version: v0.1-educaas1 -category: Blog +category: Blogging diff --git a/templates/zookeeper/config.yml b/templates/zookeeper/config.yml index 995a7d2..14ce016 100644 --- a/templates/zookeeper/config.yml +++ b/templates/zookeeper/config.yml @@ -2,7 +2,7 @@ name: Apache Zookeeper description: | (Experimental) Zookeeper cluster version: 3.4.6-rancher1 -category: clustering +category: Clustering maintainer: "Raul Sanchez " minimum_rancher_version: v0.56.0 license: