UNCLASSIFIED

Commit 4665f947 authored by Micah Nagel's avatar Micah Nagel 💰
Browse files

Update to Helm Tests

parent ce6e1735
......@@ -4,6 +4,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
---
## [0.1.6-bb.0] - 2021-05-11
### Changed
- Migrated Cypress tests to Helm tests
- Added additional testing of file storage and settings modification
## [0.1.5-bb.0] - 2021-05-06
### Changed
- Updated to 5.34.2
......
......@@ -5,5 +5,8 @@ dependencies:
- name: minio-instance
repository: file://./deps/minio
version: 2.0.9-bb.9
digest: sha256:655a9483cf53a24afb867a32f3bcdaedced200bb5cdefb93b5889f79486e8b55
generated: "2021-04-19T09:54:43.894362-06:00"
- name: bb-test-lib
repository: oci://registry.dso.mil/platform-one/big-bang/pipeline-templates/pipeline-templates
version: 0.5.2
digest: sha256:0a15fa5bcd2dafdc621740c7cd177210b2c875337f32fe78755af8806bba735a
generated: "2021-05-13T10:38:37.154607-06:00"
......@@ -2,7 +2,7 @@
apiVersion: v2
name: mattermost
type: application
version: "0.1.5-bb.0"
version: "0.1.6-bb.0"
appVersion: "5.34.2"
description: "Deployment of mattermost"
keywords:
......@@ -21,3 +21,6 @@ dependencies:
alias: minio
condition: minio.install
repository: file://./deps/minio
- name: bb-test-lib
version: 0.5.2
repository: "oci://registry.dso.mil/platform-one/big-bang/pipeline-templates/pipeline-templates"
describe('Basic Minio', function() {
it('Check Minio UI is accessible', function() {
cy.visit(Cypress.env('url'))
})
})
describe('Minio Login', function() {
it('Check Minio Login', function() {
cy.visit(Cypress.env('url')+"/minio/login")
// Fill the username
cy.get('[name="username"]')
.type(Cypress.env('accesskey'))
.should('have.value', Cypress.env('accesskey'));
// Fill the password
cy.get('[name="password"]')
.type(Cypress.env('secretkey'))
.should('have.value', Cypress.env('secretkey'));
// Locate and submit the form
cy.get('form').submit();
// Verify the app redirected you to the homepage
cy.location('pathname', { timeout: 10000 }).should('eq', '/minio/');
// Verify the page title is "Home"
cy.title().should('eq', 'MinIO Browser');
})
})
apiVersion: v1
kind: ConfigMap
metadata:
name: "{{ .Release.Name }}-cypress-test-configmap"
annotations:
"helm.sh/hook": test-success
"helm.sh/hook-weight": "5"
sidecar.istio.io/inject: "false"
labels:
helm-test: enabled
{{- include "minio.labels" . | nindent 4 }}
namespace: {{ .Release.Namespace }}
data:
{{ (.Files.Glob "cypress/*").AsConfig | indent 2 }}
kind: Pod
apiVersion: v1
metadata:
name: "{{ .Release.Name }}-ui-test"
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": test-success
"helm.sh/hook-weight": "20"
sidecar.istio.io/inject: "false"
labels:
helm-test: enabled
{{- include "minio.labels" . | nindent 4 }}
spec:
initContainers:
- name: copier
image: registry.dso.mil/platform-one/big-bang/pipeline-templates/pipeline-templates/cypress/included:5.0.0
command:
- "/bin/bash"
- "-c"
- |
ls -la /src/
cp /src/cypress.json /dest/
mkdir -p /dest/cypress/integration/
cp /src/*.js /dest/cypress/integration/
ls -la /dest/
ls -la /dest/cypress/integration/
volumeMounts:
- name: cypress-tests
mountPath: /src
- name: workdir
mountPath: /dest
containers:
- name: {{ .Release.Name }}-ui-test
image: registry.dso.mil/platform-one/big-bang/pipeline-templates/pipeline-templates/cypress/included:5.0.0
imagePullPolicy: {{ .Values.image.imagePullPolicy | quote }}
workingDir: /e2e
env:
- name: HOST
value: {{ .Values.service.port | quote }}
- name: MINIO_HOST
value: {{ include "minio.serviceName" . }}
- name: cypress_secretkey
valueFrom:
secretKeyRef:
name: {{ .Values.minioRootCreds }}
key: secretkey
- name: cypress_accesskey
valueFrom:
secretKeyRef:
name: {{ .Values.minioRootCreds }}
key: accesskey
- name: cypress_url
value: "http://{{ include "minio.serviceName" . }}:{{ .Values.service.port }}"
args:
- "--"
- "--reporter-options=list"
- "--reporter=spec"
volumeMounts:
- name: workdir
mountPath: /e2e/
restartPolicy: Never
volumes:
- name: cypress-tests
configMap:
name: "{{ .Release.Name }}-cypress-test-configmap"
- name: workdir
emptyDir: {}
kind: Pod
apiVersion: v1
metadata:
name: "{{ .Release.Name }}-access-test"
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": test-success
"helm.sh/hook-weight": "10"
sidecar.istio.io/inject: "false"
labels:
helm-test: enabled
{{- include "minio.labels" . | nindent 4 }}
spec:
containers:
- name: {{ .Release.Name }}-credentials-test
image: {{.Values.mcImage }}
imagePullPolicy: {{ .Values.image.imagePullPolicy | quote }}
env:
- name: MINIO_PORT
value: {{ .Values.service.port | quote }}
- name: MINIO_HOST
value: {{ include "minio.serviceName" . }}
- name: SECRET_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.minioRootCreds }}
key: secretkey
- name: ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ .Values.minioRootCreds }}
key: accesskey
command:
- /bin/bash
- -ec
- |-
set -x
mc config host add bigbang http://${MINIO_HOST}:${MINIO_PORT} ${ACCESS_KEY} ${SECRET_KEY}
# cleanup from pervious runs
mc rb bigbang/foobar --force || true
mc mb bigbang/foobar
mc ls bigbang/foobar
base64 /dev/urandom | head -c 10000000 > /tmp/file.txt
md5sum /tmp/file.txt > /tmp/filesig
mc cp /tmp/file.txt bigbang/foobar/file.txt
mc ls bigbang/foobar/file.txt
mc cp bigbang/foobar/file.txt /tmp/file.txt
mc rb bigbang/foobar --force
md5sum -c /tmp/filesig
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 4}}
{{- end }}
restartPolicy: Never
\ No newline at end of file
{{- include "bb-test-lib.cypress-configmap.overrides" (list . "mattermost-test.cypress-configmap") }}
{{- define "mattermost-test.cypress-configmap" }}
metadata:
labels:
{{ include "mattermost.labels" . | nindent 4 }}
{{- end }}
---
{{- include "bb-test-lib.cypress-runner.overrides" (list . "mattermost-test.cypress-runner") -}}
{{- define "mattermost-test.cypress-runner" -}}
metadata:
labels:
{{ include "mattermost.labels" . | nindent 4 }}
{{- end }}
describe('Basic Mattermost', function() {
it('Check Mattermost is accessible', function() {
cy.visit(Cypress.env('mm_url'))
// Wait for redirects to happen
describe('Mattermost Healthcheck', function() {
// This provides us with a login account on fresh installs
before(() => {
cy.visit(Cypress.env('url'))
cy.get('div[id="root"]').should('be.visible')
// Check if this is a fresh install or upgrade
cy.url().then(($url) => {
if ($url.includes('signup')) {
cy.get('input[id="email"]').type(Cypress.env('mm_email'))
cy.get('input[id="name"]').type(Cypress.env('mm_user'))
cy.get('input[id="password"]').type(Cypress.env('mm_password'))
cy.get('button[id="createAccountButton"]').click()
}
})
})
beforeEach(() => {
cy.visit(Cypress.env('url'))
cy.get('div[id="root"]').should('be.visible')
// Check if login is needed
cy.url().then(($url) => {
if ($url.includes('login')) {
cy.get('input[id="loginId"]').type(Cypress.env('mm_user'))
cy.get('input[id="loginPassword"]').type(Cypress.env('mm_password'))
cy.get('button[id="loginButton"]').click()
}
})
cy.wait(500)
})
it('should create / persist teams', function() {
cy.get("body").then($body => {
if ($body.find('a[id="createNewTeamLink"]').length > 0) {
cy.get('a[id="createNewTeamLink"]').click()
cy.get('input[id="teamNameInput"]').type(Cypress.env('mm_user'))
cy.get('input[id="teamNameInput"]').type("Big Bang")
cy.get('button[id="teamNameNextButton"]').click()
cy.get('button[id="teamURLFinishButton"]').click()
cy.title().should('include', 'Town Square - Big Bang')
} else {
cy.title().should('include', 'Town Square - Big Bang')
}
})
cy.get("body").then($body => {
if ($body.find('a[id="tutorialSkipLink"]').length > 0) {
cy.get('a[id="tutorialSkipLink"]').click()
}
})
})
cy.title().should('include', 'Town Square - ')
it('should allow chatting', function() {
let randomChat = "Hello " + Math.random().toString(36).substring(8);
cy.get('textarea[id="post_textbox"]').type(randomChat).type('{enter}')
cy.get('p').contains(randomChat).should('be.visible')
})
cy.get('a[id="tutorialSkipLink"]').click()
cy.get('textarea[id="post_textbox"]').type("Hello Big Bang").type('{enter}')
cy.get('p').contains("Hello Big Bang").should('be.visible')
} else {
cy.get('input[id="loginId"]').type(Cypress.env('mm_user'))
cy.get('input[id="loginPassword"]').type(Cypress.env('mm_password'))
cy.get('button[id="loginButton"]').click()
it('should have file storage connection', function() {
cy.get('button[aria-label="main menu"]').click()
cy.get('a[href="/admin_console"]').click()
cy.title().should('include', 'Town Square - ')
cy.get('a[id="environment/file_storage"]').click()
cy.get('span').contains("Test Connection").click()
cy.get('div[class="alert alert-success"]').should('be.visible')
})
// Safeguard in case tutorial link is still there
cy.get("body").then($body => {
if ($body.find('a[id="tutorialSkipLink"]').length > 0) {
cy.get('a[id="tutorialSkipLink"]').click()
}
})
it('should save settings changes', function() {
cy.get('button[aria-label="main menu"]').click()
cy.get('a[href="/admin_console"]').click()
cy.get('textarea[id="post_textbox"]').type("Hello upgraded Big Bang").type('{enter}')
cy.get('p').contains("Hello upgraded Big Bang").should('be.visible')
}
})
cy.get('a[id="site_config/customization"]').click()
let randomName = Math.random().toString(36).substring(8);
cy.get('input[id="TeamSettings.SiteName"]').clear().type(randomName)
cy.get('button[id="saveSetting"]').click()
cy.reload()
cy.title().should('include', randomName)
})
})
#!/usr/bin/env bash
echo "Running Cypress e2e tests headlessly without copying files"
# explanation of the "docker run" command line arguments
#
# -it = interactive terminal
# -v $PWD:/e2e = map current folder to /e2e inside the container
# -w /e2e = set working directy to /e2e
# $@ = pass any arguments to this script to the Cypress command
# like "./cy-run.sh --record"
#
# Docker image "cypress/included:3.2.0" has its entrypoint
# set to "cypress run" by default
docker run -it -v $PWD:/e2e -w /e2e cypress/included:5.0.0 $@
{
"pluginsFile": false,
"supportFile": false,
"fixturesFolder": false,
"env": {
"mm_url": "chat.bigbang.dev",
"mm_email": "test@bigbang.dev",
"mm_user": "bigbang",
"mm_password": "Bigbang#123"
}
}
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: main
namespace: istio-system
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- '*'
port:
name: http
number: 80
protocol: HTTP
tls:
httpsRedirect: true
- hosts:
- '*.bigbang.dev'
port:
name: https
number: 443
protocol: HTTPS
tls:
credentialName: wildcard-cert
mode: SIMPLE
istio:
enabled: true
minio:
install: true
postgresql:
install: true
bbtests:
cypress:
artifacts: true
envs:
cypress_url: http://mattermost.mattermost.svc.cluster.local:8065
cypress_mm_email: "test@bigbang.dev"
cypress_mm_user: "bigbang"
cypress_mm_password: "Bigbang#123"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment