README ¶
ODS Quickstarters - tests
All tests of quickstarters follow the same scheme:
- a single test file, named
jenkinsfile_test.go
, inside a folder named exactly as thequickstarter type
(e.g. be-golang-plain) - which provisions a quickstarter, and then runs thejenkinsfile
of the newly created component to build and deploy it - a directory
golden
housing golden records for the jenkins stages of the two runs (provision and build), as well as from sonarqube to verify the actual responses against - a quickstarter test always provisions the component into an ODS created namespace called
unitt
- which is created by the tests in ods-core. So those tests must be run first, thrumake test
inods-core/tests
ATTENTION: For the tests to work the cd_user
configured in ods-configuration/ods-core.env
MUST have rights to create and manage a bitbucket project
Anatomy of a quickstarter test
Lets look at a single test in detail - in this case the one for spring boot
- Create the bitbucket repository for the quickstarter (and bitbucket project if needed)
// cleanup and create bb resources for this test
utils.CleanupAndCreateBitbucketProjectAndRepo(
quickstarterName, componentId)
- Start the provisioning of a quickstarter thru the webhook proxy
// run provision job for quickstarter in project's cd jenkins
stages, err := utils.RunJenkinsFile(
"ods-quickstarters", // the repository
values["ODS_BITBUCKET_PROJECT"],
values["ODS_GIT_REF"], // branch on ods-quickstarters
coreUtils.PROJECT_NAME,
fmt.Sprintf("%s/Jenkinsfile", quickstarterName),
coreUtils.PROJECT_NAME_CD,
coreUtils.EnvPair{
Name: "COMPONENT_ID",
Value: componentId,
},
coreUtils.EnvPair{
Name: "GIT_URL_HTTP",
Value: fmt.Sprintf("%s/%s/%s.git", values["REPO_BASE"], coreUtils.PROJECT_NAME, componentId),
},
)
-
Verify expected stages from the
golden
provisioning record against the jenkins createdstages
-
Trigger a jenkins build run instance (for the provisioned component)
// run master build of provisioned quickstarter in project's cd jenkins
stages, err = utils.RunJenkinsFile(
repoName,
coreUtils.PROJECT_NAME,
"master", // branch
coreUtils.PROJECT_NAME,
"Jenkinsfile",
coreUtils.PROJECT_NAME_CD,
coreUtils.EnvPair{
Name: "COMPONENT_ID",
Value: componentId,
},
)
-
Verify expected stages from the
golden
run / build record against the responsestages
-
Verify the created OCP artifacts, and if pods / deployments are available - thru tailor diff
resourcesInTest := coreUtils.Resources{
Namespace: coreUtils.PROJECT_NAME_DEV,
ImageTags: []coreUtils.ImageTag{{Name: componentId, Tag: "latest"}},
BuildConfigs: []string{componentId},
DeploymentConfigs: []string{componentId},
Services: []string{componentId},
ImageStreams: []string{componentId},
}
All necessary utils, except for scripts are housed in ods-core/tests
Running the tests
just run make test
in the this directory
Click to show internal directories.
Click to hide internal directories.