Add template validation, fix categories

This commit is contained in:
James Oliver 2016-03-28 22:09:56 -07:00
parent 91ee360307
commit bc26eb978e
27 changed files with 81 additions and 28 deletions

View File

@ -3,6 +3,8 @@ import cattle
import subprocess import subprocess
import sys import sys
import os import os
import re
# import yaml
def _base(): def _base():
@ -49,12 +51,33 @@ def catalog_service(catalog_bin):
return CatalogService(catalog_bin) return CatalogService(catalog_bin)
@pytest.fixture @pytest.fixture(scope='session')
def client(): def client():
url = 'http://localhost:8088/v1-catalog/schemas' url = 'http://localhost:8088/v1-catalog/schemas'
return cattle.from_env(url=url) 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): def test_validate_exits_normal(catalog_service):
catalog_service.assert_retcode( catalog_service.assert_retcode(
0, '-catalogUrl', 0, '-catalogUrl',
@ -62,6 +85,35 @@ def test_validate_exits_normal(catalog_service):
'-validate', '-port', '18088') '-validate', '-port', '18088')
def test_catalog_list(client): def test_stack_name(templates):
templates = client.list_template() hostname_label = re.compile(r'^[a-zA-Z0-9\-]{1,63}$')
assert len(templates) > 0 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

View File

@ -1,4 +1,5 @@
cattle==0.5.1 cattle==0.5.3
pyyaml==3.11
flake8 flake8
pytest==2.3.5 pytest==2.8.7

View File

@ -1,4 +1,4 @@
name: "K8s Example Guestbook" name: "K8s Example Guestbook"
description: "It's a guestbook" description: "It's a guestbook"
version: 1.0.0 version: 1.0.0
category: Test category: Blogging

View File

@ -1,4 +1,4 @@
name: "K8s Example WordPress" name: "K8s Example WordPress"
description: "Blogging platform" description: "Blogging platform"
version: 1.0.0 version: 1.0.0
category: "Blog tool, publishing platform and CMS" category: Blogging

View File

@ -2,4 +2,4 @@ name: Wordpress
description: | description: |
Blog tool, publishing platform and CMS Blog tool, publishing platform and CMS
version: latest-rancher1 version: latest-rancher1
category: Blog category: Blogging

View File

@ -2,4 +2,4 @@ name: MongoDB
description: | description: |
MongoDB Replica Set. MongoDB Replica Set.
version: 3.2-rancher1 version: 3.2-rancher1
category: Database category: Databases

View File

@ -1,5 +1,5 @@
name: Alfresco name: Alfresco
description: | description: |
Slef hosted your EDM with Alfresco on few seconds. An ECM and BPM platform.
version: 5.1.0 version: 5.1.0
category: EDM category: EDM

View File

@ -1,6 +1,6 @@
.catalog: .catalog:
name: Drone Rancher Node Manager name: Drone Rancher Node Manager
version: 0.1.0-cloundautique1 version: 0.1.0-cloudnautique1
description: | description: |
(Experimental) Poll Rancher Metadata for Drone Agents (Experimental) Poll Rancher Metadata for Drone Agents
and add/remove nodes accordingly. and add/remove nodes accordingly.

View File

@ -2,5 +2,5 @@ name: Drone Rancher Node Manager
description: | description: |
(Experimental) Dynamically add remove Drone worker nodes (Experimental) Dynamically add remove Drone worker nodes
version: 0.1.0-cloudnautique1 version: 0.1.0-cloudnautique1
category: "Continuous Integration" category: Continuous Integration
minimum_rancher_version: v0.56.0 minimum_rancher_version: v0.56.0

View File

@ -1,6 +1,6 @@
.catalog: .catalog:
name: "Elasticsearch" name: "Elasticsearch"
version: "2.2.1-rancher1" version: "2.2.2-rancher1"
description: "Elasticsearch. You know, for search" description: "Elasticsearch. You know, for search"
questions: questions:
- variable: cluster_name - variable: cluster_name

View File

@ -2,4 +2,4 @@ name: MariaDB Galera Cluster
description: | description: |
(Experimental) Synchronous multi-master cluster for MariaDB (Experimental) Synchronous multi-master cluster for MariaDB
version: 10.0.22-rancher1 version: 10.0.22-rancher1
category: Database category: Databases

View File

@ -2,7 +2,7 @@ name: gocd-agent
description: | description: |
(Experimental) Gocd agent (Experimental) Gocd agent
version: 16.2.1-rancher1 version: 16.2.1-rancher1
category: "Continuous Integration" category: Continuous Integration
maintainer: "Raul Sanchez <rawmind@gmail.com>" maintainer: "Raul Sanchez <rawmind@gmail.com>"
minimum_rancher_version: v0.59.0 minimum_rancher_version: v0.59.0
license: license:

View File

@ -2,7 +2,7 @@ name: gocd-server
description: | description: |
(Experimental) Gocd server (Experimental) Gocd server
version: 16.2.1-rancher1 version: 16.2.1-rancher1
category: "Continuous Integration" category: Continuous Integration
maintainer: "Raul Sanchez <rawmind@gmail.com>" maintainer: "Raul Sanchez <rawmind@gmail.com>"
minimum_rancher_version: v0.59.0 minimum_rancher_version: v0.59.0
license: license:

View File

@ -2,6 +2,6 @@ name: Janitor
description: | description: |
Automatic cleanup of unused images on hosts, in order to save disk space. Automatic cleanup of unused images on hosts, in order to save disk space.
version: v1.5.2 version: v1.5.2
category: monitoring category: Monitoring
maintainer: Steve Shipway <s.shipway@auckland.ac.nz> maintainer: Steve Shipway <s.shipway@auckland.ac.nz>

View File

@ -1,8 +1,8 @@
name: Apache Kafka name: Apache Kafka
description: | description: |
(Experimental) Kafka cluster (Experimental) Kafka cluster
version: 0.8.2-rancher1 version: 0.9.0-rancher1
category: clustering category: Clustering
maintainer: "Raul Sanchez <rawmind@gmail.com>" maintainer: "Raul Sanchez <rawmind@gmail.com>"
minimum_rancher_version: v0.56.0 minimum_rancher_version: v0.56.0
license: license:

View File

@ -2,5 +2,5 @@ name: Minecraft
description: | description: |
Multiplayer block game for wasting lots of time Multiplayer block game for wasting lots of time
version: v1.8 version: v1.8
category: entertainment category: Entertainment
maintainer: Steve Shipway <s.shipway@auckland.ac.nz> maintainer: Steve Shipway <s.shipway@auckland.ac.nz>

View File

@ -1,6 +1,6 @@
.catalog: .catalog:
name: "Nuxeo Platform" name: "Nuxeo Platform"
version: "rancher-1.0" version: 8.1-rancher1
description: | description: |
Enterprise Content Management Enterprise Content Management
Platform for Business Applications Platform for Business Applications

View File

@ -2,5 +2,5 @@ name: Nuxeo Platform
description: | description: |
Enterprise Content Management Enterprise Content Management
Platform for Business Applications Platform for Business Applications
version: 8.1 version: 8.1-rancher1
category: ECM category: ECM

View File

@ -1,6 +1,6 @@
.catalog: .catalog:
name: "Odoo" name: "Odoo"
version: "0.1-educaas" version: v0.1-educaas
description: "ERP management powered by Odoo" description: "ERP management powered by Odoo"
uuid: odoo-0 uuid: odoo-0
questions: questions:

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1,6 +1,6 @@
.catalog: .catalog:
name: "Taiga" name: "Taiga"
version: "v0.1-educaas" version: "v0.1-educaas1"
description: "Project management platform for agile developers" description: "Project management platform for agile developers"
uuid: taiga-0 uuid: taiga-0
minimum_rancher_version: v0.51.0 minimum_rancher_version: v0.51.0

View File

@ -1,6 +1,6 @@
.catalog: .catalog:
name: "Wordpress" name: "Wordpress"
version: "v0.1-educaas" version: "v0.1-educaas1"
description: "Blog tool, publishing platform and CMS" description: "Blog tool, publishing platform and CMS"
uuid: Wordpress-0 uuid: Wordpress-0
minimum_rancher_version: v0.51.0 minimum_rancher_version: v0.51.0

View File

@ -2,4 +2,4 @@ name: Wordpress
description: | description: |
Blog tool, publishing platform and CMS Blog tool, publishing platform and CMS
version: v0.1-educaas1 version: v0.1-educaas1
category: Blog category: Blogging

View File

@ -2,7 +2,7 @@ name: Apache Zookeeper
description: | description: |
(Experimental) Zookeeper cluster (Experimental) Zookeeper cluster
version: 3.4.6-rancher1 version: 3.4.6-rancher1
category: clustering category: Clustering
maintainer: "Raul Sanchez <rawmind@gmail.com>" maintainer: "Raul Sanchez <rawmind@gmail.com>"
minimum_rancher_version: v0.56.0 minimum_rancher_version: v0.56.0
license: license: