[bitnami/jenkins] Add Jenkins Helm Chart tests (#10173)

* [bitnami/jenkins] Add Jenkins Helm Chart tests

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Remove explicit timeouts

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Update some test titles

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Format index.js

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Add credential test

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Apply feedback on selectors

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>

* Add vib-publish pipelines changes

Signed-off-by: Jose Antonio Carmona <jcarmona@vmware.com>
This commit is contained in:
Jose Antonio Carmona
2022-05-17 10:09:16 +02:00
committed by GitHub
parent 966db2264d
commit b5d3d6e9e3
11 changed files with 280 additions and 2 deletions
+8
View File
@@ -0,0 +1,8 @@
{
"baseUrl": "http://localhost",
"defaultCommandTimeout": 30000,
"env": {
"username": "user",
"password": "ComplicatedPassword123!4"
}
}
@@ -0,0 +1,8 @@
{
"newUserAndPass": {
"id": "phoenix",
"kind": "Username with password",
"username": "b1t1",
"password": "zdrava"
}
}
@@ -0,0 +1,7 @@
{
"freestyleProject": {
"name": "GitProjectTest",
"type": "Freestyle project",
"repositoryURL": "https://github.com/bitnami/charts"
}
}
@@ -0,0 +1,8 @@
{
"newUser1": {
"username": "janedoe",
"password": "somePass12345",
"fullname": "Jane Jessica Doe",
"email": "jane@example.com"
}
}
@@ -0,0 +1,102 @@
/// <reference types="cypress" />
import { random, checkErrors } from './utils';
it('allows to create system credentials', () => {
cy.login();
cy.visit('/credentials/store/system/domain/_/newCredentials');
cy.fixture('credentials').then((credential) => {
cy.contains('div.jenkins-form-item', 'Kind').within(() => {
cy.get('select').select(credential.newUserAndPass.kind);
});
cy.get('[name="_.username"]').type(
`${credential.newUserAndPass.username}-${random}`
);
cy.get('[name="_.password"]').type(credential.newUserAndPass.password);
cy.get('[name="_.id"]').type(`${credential.newUserAndPass.id}-${random}`);
cy.contains('button', 'OK').click();
cy.visit(
`/credentials/store/system/domain/_/credential/${credential.newUserAndPass.id}-${random}`
);
cy.contains(`${credential.newUserAndPass.username}-${random}`);
});
});
it('should be possible to create a new Jenkins pipeline', () => {
cy.login();
cy.visit('/view/All/newJob');
cy.fixture('items').then((item) => {
cy.get('#name').type(`${item.freestyleProject.name}-${random}`);
cy.contains(item.freestyleProject.type).click();
cy.contains('button', 'OK').should('be.enabled').click();
cy.contains('Error').should('not.be.visible');
cy.get('.radio-block-start').contains('Git').click();
cy.get("[name*='url']").type(item.freestyleProject.repositoryURL);
cy.contains('button', 'Save').click();
cy.contains('h1', item.freestyleProject.name);
});
// As a new Git project is created in every execution, the next build
// will always be the first one.
const nextBuildNumber = 1;
cy.get("a[title='Build Now']").click();
cy.contains(`#${nextBuildNumber}`);
cy.get("a[title='Build Now']");
// Depending on the setup, the node where to execute the build needs to be
// provisioned, which can take up some time
cy.get(`a[href$='/${nextBuildNumber}/'][class*='display-name']`).click();
cy.fixture('items').then((item) => {
cy.visit(
`/job/${item.freestyleProject.name}-${random}/${nextBuildNumber}/`
);
cy.contains(`Build #${nextBuildNumber}`);
cy.contains('Build has been executing for');
});
});
it('should be possible to register a new user', () => {
cy.login();
cy.visit('/securityRealm/addUser');
cy.contains('Create User');
cy.fixture('users').then((user) => {
cy.get('#username').type(`${user.newUser1.username}-${random}`);
cy.get("[name='password1']").type(user.newUser1.password);
cy.get("[name='password2']").type(user.newUser1.password);
cy.get("[name='fullname']").type(`${user.newUser1.fullname}-${random}`);
cy.get("[name='email']").type(`${random}-${user.newUser1.email}`);
cy.contains('button', 'Create User').click();
cy.visit('/securityRealm');
cy.contains('Users');
cy.contains(`${user.newUser1.username}-${random}`);
});
});
it('should not report any configuration errors', () => {
cy.login();
cy.visit('/manage');
const errorAllowedList = [];
cy.get('body').then(($body) => {
if ($body.find('.alert-danger').length > 0) {
checkErrors('.alert-danger', errorAllowedList);
} else {
cy.log('No error messages found in the UI');
}
});
});
it('should list the built-in node', () => {
cy.login();
cy.visit('/computer');
cy.contains('Manage nodes and clouds');
cy.get('table#computers').within(() => {
cy.contains('tr', 'Built-In Node');
});
});
@@ -0,0 +1,20 @@
/// <reference types="cypress" />
export let random = (Math.random() + 1).toString(36).substring(7);
export const checkErrors = (selector, allowedList) => {
cy.get(selector).then(($errors) => {
const errorMessages = [];
for (let index = 0; index < $errors.length; index++) {
const errorMsg = $errors[index].outerText;
const visible = Cypress.$($errors[index]).is(':visible');
if (visible && !allowedList.includes(errorMsg)) {
cy.log(
`The following misconfiguration message appears in the UI: ${errorMsg}`
);
errorMessages.push(errorMsg);
}
}
expect(errorMessages).to.be.empty;
});
};
@@ -0,0 +1,23 @@
const COMMAND_DELAY = 800;
for (const command of ['click']) {
Cypress.Commands.overwrite(command, (originalFn, ...args) => {
const origVal = originalFn(...args);
return new Promise((resolve) => {
setTimeout(() => {
resolve(origVal);
}, COMMAND_DELAY);
});
});
}
Cypress.Commands.add(
'login',
(username = Cypress.env('username'), password = Cypress.env('password')) => {
cy.visit('/login');
cy.get('#j_username').type(username);
cy.get('[name=j_password]').type(password);
cy.contains('Sign in').click();
}
);
@@ -0,0 +1,20 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';
// Alternatively you can use CommonJS syntax:
// require('./commands')
+32
View File
@@ -0,0 +1,32 @@
command:
jenkins-cli:
exec: java -jar /bitnami/jenkins/home/war/WEB-INF/lib/cli-${APP_VERSION}.jar -s http://localhost:8080 -auth ${JENKINS_USERNAME}:${JENKINS_PASSWORD} help
exit-status: 0
stdout: []
stderr: []
timeout: 20000
jenkins-cli-user:
exec: java -jar /bitnami/jenkins/home/war/WEB-INF/lib/cli-${APP_VERSION}.jar -s http://localhost:8080 -auth ${JENKINS_USERNAME}:${JENKINS_PASSWORD} who-am-i
exit-status: 0
stdout:
- {{ printf "Authenticated as: %s" .Env.JENKINS_USERNAME | quote }}
stderr: []
timeout: 20000
user-id-test:
exec: if [ "$(id -u)" -eq 0 ]; then exit 1; fi
exit-status: 0
stdout: []
stderr: []
file:
/opt/bitnami/jenkins/jenkins.war:
# Jenkins Web Application Resource
exists: true
mode: "0644"
owner: root
group: root
filetype: file
/bitnami/jenkins/home:
# Path where Jenkins resources live (JENKINS_HOME)
exists: true
mode: "2755"
filetype: directory
+26 -1
View File
@@ -22,7 +22,7 @@
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/jenkins"
},
"runtime_parameters": "ImplbmtpbnNQYXNzd29yZCI6ICJTMzlCS1dqU2toIgoicG9kQWZmaW5pdHlQcmVzZXQiOiAiaGFyZCIKInBvZEFudGlBZmZpbml0eVByZXNldCI6ICIiCiJzZXJ2aWNlIjoKICAicG9ydCI6IDgwCiAgInR5cGUiOiAiTG9hZEJhbGFuY2VyIg==",
"runtime_parameters": "amVua2luc1VzZXI6ICJ1c2VyIgpqZW5raW5zUGFzc3dvcmQ6ICJDb21wbGljYXRlZFBhc3N3b3JkMTIzITQiCnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAo=",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
@@ -46,6 +46,31 @@
"endpoint": "lb-jenkins-http",
"app_protocol": "HTTP"
}
},
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib/jenkins/goss"
},
"remote": {
"workload": "deploy-jenkins"
}
}
},
{
"action_id": "cypress",
"params": {
"resources": {
"path": "/.vib/jenkins/cypress"
},
"endpoint": "lb-jenkins-http",
"app_protocol": "HTTP",
"env": {
"username": "user",
"password": "ComplicatedPassword123!4"
}
}
}
]
},
+26 -1
View File
@@ -22,7 +22,7 @@
"url": "{SHA_ARCHIVE}",
"path": "/bitnami/jenkins"
},
"runtime_parameters": "ImplbmtpbnNQYXNzd29yZCI6ICJTMzlCS1dqU2toIgoicG9kQWZmaW5pdHlQcmVzZXQiOiAiaGFyZCIKInBvZEFudGlBZmZpbml0eVByZXNldCI6ICIiCiJzZXJ2aWNlIjoKICAicG9ydCI6IDgwCiAgInR5cGUiOiAiTG9hZEJhbGFuY2VyIg==",
"runtime_parameters": "amVua2luc1VzZXI6ICJ1c2VyIgpqZW5raW5zUGFzc3dvcmQ6ICJDb21wbGljYXRlZFBhc3N3b3JkMTIzITQiCnNlcnZpY2U6CiAgdHlwZTogTG9hZEJhbGFuY2VyCiAgcG9ydHM6CiAgICBodHRwOiA4MAo=",
"target_platform": {
"target_platform_id": "{VIB_ENV_TARGET_PLATFORM}",
"size": {
@@ -44,6 +44,31 @@
"endpoint": "lb-jenkins-http",
"app_protocol": "HTTP"
}
},
{
"action_id": "goss",
"params": {
"resources": {
"path": "/.vib/jenkins/goss"
},
"remote": {
"workload": "deploy-jenkins"
}
}
},
{
"action_id": "cypress",
"params": {
"resources": {
"path": "/.vib/jenkins/cypress"
},
"endpoint": "lb-jenkins-http",
"app_protocol": "HTTP",
"env": {
"username": "user",
"password": "ComplicatedPassword123!4"
}
}
}
]
}