-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the cluster version matches configuration
We introduce a test to verify the running Kubernetes version against our list of versions from the buildchain. Note: we create a symlink, under `tests/versions.py`, pointing to `buildchain/buildchain/versions.py`, for ease of importation within tests. Issue: #640
- Loading branch information
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@post @ci @local | ||
Feature: Check versions in the running cluster | ||
Scenario: Check the cluster's Kubernetes version | ||
Given the Kubernetes API is available | ||
Then the Kubernetes version deployed is the same as the configured one |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from kubernetes.client import VersionApi | ||
from pytest_bdd import scenario, then | ||
|
||
from tests import versions | ||
|
||
|
||
# Scenarios | ||
@scenario('../features/versions.feature', | ||
"Check the cluster's Kubernetes version") | ||
def test_cluster_version(host): | ||
pass | ||
|
||
|
||
# Then | ||
@then('the Kubernetes version deployed is the same as the configured one') | ||
def check_kubernetes_version(k8s_apiclient): | ||
# NOTE: the `vX.Y.Z` format is used by Kubernetes, not our buildchain | ||
configured_version = 'v{}'.format(versions.K8S_VERSION) | ||
|
||
k8s_client = VersionApi(api_client=k8s_apiclient) | ||
observed_version = k8s_client.get_code().git_version | ||
|
||
assert configured_version == observed_version, ( | ||
"The running version of Kubernetes is '{}', while the expected version" | ||
"is '{}'.".format(observed_version, configured_version) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../buildchain/buildchain/versions.py |