Skip to content

Instantly share code, notes, and snippets.

@clhynfield
Last active July 15, 2019 12:23
Show Gist options
  • Save clhynfield/ad11e0c92cb8a11a13df402aa87c338a to your computer and use it in GitHub Desktop.
Save clhynfield/ad11e0c92cb8a11a13df402aa87c338a to your computer and use it in GitHub Desktop.
Test-driving Ops Manager version as code

Version Ops Manager via code

As a Platform Engineer, I want to select the version of Ops Manager with a config file So that I can manage software life cycle via source control

Given access to a paved IaaS
  And a PCF config-as-code repo
  And a Control Plane for PCF

 When a code commit to an Ops Manager version config is pushed

 Then there is an Ops Manager running
  And the running Ops Manager version matches the desired version in the code

Value of this and any decent test:

  • There is no errand, no other programmatic test of version-as-code
  • Engineers new or returning to the code can learn how it works through the tests
  • It forces the engineering pair to think through the problem and produce a more articulate solution
---
platform: linux
inputs:
- name: config # contains the OpsMan configuration file
- name: env # contains the environment information for OpsMan
params:
ENV_FILE: env.yml
# - Required
# - filepath of the env config YAML
# - relative to root of the `env` input
OPSMAN_VERSION_FILE: opsman/version.yml
# - Required
# - filepath of the opsman config YAML
# - relative to root of the `config` input
run:
path: bash
args:
- "-c"
- |
cat /var/version && echo ""
p-automator -v
set -eux
opsman_current_version="$(
om \
--env env/"${ENV_FILE}" \
curl \
--silent \
--path /api/v0/info \
| om interpolate --path /info/version
)"
opsman_expected_version="$(
om interpolate \
--config config/"${OPSMAN_VERSION_FILE}" \
--path '/product-version'
)"
if [[ "$opsman_current_version" = "$opsman_expected_version" ]]; then
echo "Ops Manager is at the expected version ($opsman_expected_version)"
else
echo "Ops Manager is at version $opsman_current_version, " \
"expected version $opsman_expected_version" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment