This commit is contained in:
Tim Park 2018-12-26 08:53:42 -08:00
Родитель 95b2ff7147
Коммит 2d4d25a167
7 изменённых файлов: 94 добавлений и 3 удалений

Просмотреть файл

@ -6,7 +6,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestGenerate(t *testing.T) {
func TestGenerateJSON(t *testing.T) {
components, err := Generate("../test/fixtures/generate", "prod")
assert.Nil(t, err)
@ -25,3 +25,20 @@ func TestGenerate(t *testing.T) {
assert.Equal(t, "kibana", components[5].Name)
assert.Equal(t, 1595, len(components[5].Manifest))
}
func TestGenerateYAML(t *testing.T) {
components, err := Generate("../test/fixtures/generate-yaml", "prod")
assert.Nil(t, err)
assert.Equal(t, 3, len(components))
assert.Equal(t, "prometheus-grafana", components[0].Name)
assert.Equal(t, 125, len(components[0].Manifest))
assert.Equal(t, "grafana", components[1].Name)
assert.Equal(t, 8159, len(components[1].Manifest))
assert.Equal(t, "prometheus", components[2].Name)
assert.Equal(t, 21023, len(components[2].Manifest))
}

Просмотреть файл

@ -6,13 +6,13 @@ import (
"github.com/stretchr/testify/assert"
)
func TestInstall(t *testing.T) {
func TestInstallJSON(t *testing.T) {
err := Install("../test/fixtures/install")
assert.Nil(t, err)
}
func TestInstallYaml(t *testing.T) {
func TestInstallYAML(t *testing.T) {
err := Install("../test/fixtures/install-yaml")
assert.Nil(t, err)

Просмотреть файл

@ -51,6 +51,7 @@ func GenerateHelmComponent(component *core.Component) (manifest string, err erro
configYaml, err := yaml.Marshal(&component.Config.Config)
if err != nil {
log.Errorf("marshalling config yaml for helm generated component '%s' failed with: %s\n", component.Name, err.Error())
return "", err
}
@ -71,6 +72,7 @@ func GenerateHelmComponent(component *core.Component) (manifest string, err erro
manifests, err := exec.Command("docker", "run", "--rm", "-v", volumeMount, "alpine/helm:latest", "template", "/app/chart", "--values", "/app/chart/overriddenValues.yaml", "--name", name).Output()
if err != nil {
log.Errorf("helm template failed with: %s\n", err.Error())
return "", err
}

12
test/fixtures/install-yaml/component.yaml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,12 @@
name: "elasticsearch-fluentd-kibana"
generator: "static"
path: "./manifests"
subcomponents:
- name: "grafana"
generator: "helm"
repo: "https://github.com/helm/charts"
path: "stable/grafana"
- name: "prometheus"
generator: "helm"
repo: "https://github.com/helm/charts"
path: "stable/prometheus"

52
test/fixtures/install-yaml/config/common.yaml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,52 @@
config:
subcomponents:
prometheus:
config:
namespace: "prometheus"
adminUser: "ops"
alertmanager:
persistentVolume:
storageClass: "default"
server:
persistentVolume:
storageClass": "default"
grafana:
config:
namespace: "grafana"
datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server.prometheus.svc.cluster.local
access: proxy
isDefault: true
dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: default
orgId: 1
folder:
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards/default
dashboards:
default:
cluster-metrics:
gnetId: 6417
revision: 1
datasource: Prometheus
persistent-volumes:
gnetId: 6739
revision: 1
datasource: Prometheus
persistence:
enabled: true
storageClassName: default
accessModes:
- ReadWriteOnce
size: 4Gi

4
test/fixtures/install-yaml/manifests/grafana-namespace.yaml поставляемый Normal file
Просмотреть файл

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: grafana

Просмотреть файл

@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: prometheus