tests

module
v0.0.0-...-2bafc8d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2020 License: Apache-2.0

README

ODS Quickstarters - tests

All tests of quickstarters follow the same scheme:

  1. a single test file, named jenkinsfile_test.go, inside a folder named exactly as the quickstarter type (e.g. be-golang-plain) - which provisions a quickstarter, and then runs the jenkinsfile of the newly created component to build and deploy it
  2. 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
  3. 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, thru make test in ods-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

  1. Create the bitbucket repository for the quickstarter (and bitbucket project if needed)
	// cleanup and create bb resources for this test
	utils.CleanupAndCreateBitbucketProjectAndRepo(
		quickstarterName, componentId)
  1. 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),
		},
	)
  1. Verify expected stages from the golden provisioning record against the jenkins created stages

  2. 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,
		},
	)
  1. Verify expected stages from the golden run / build record against the response stages

  2. 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL