-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add functional tests #84
Open
gbenhaim
wants to merge
1
commit into
ansibleplaybookbundle:master
Choose a base branch
from
gbenhaim:add_functional_tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,77 @@ | ||
#!/bin/bash -xe | ||
|
||
kcmd() { | ||
local kubevirt="${KUBEVIRT_REPO_PATH:?Please export KUBEVIRT_REPO_PATH variable}" | ||
|
||
( cd "$kubevirt"; "$@" ) | ||
} | ||
|
||
cluster_up() { | ||
kcmd make cluster-up | ||
} | ||
|
||
cluster_down() { | ||
kcmd make cluster-down | ||
} | ||
|
||
cluster_sync() { | ||
local registry_port | ||
registry_port="$(get_public_port 5000)" | ||
local num_of_nodes=${KUBEVIRT_NUM_NODES:-1} | ||
local image_name="registry:5000/kubevirt-apb/kubevirt" | ||
local node | ||
|
||
make apb_build DOCKERHOST="localhost:${registry_port}" | ||
make docker_push DOCKERHOST="localhost:${registry_port}" | ||
|
||
for ((i=1; i<=num_of_nodes; i++)); do | ||
node="node$(printf "%02d" "$i")" | ||
kcmd cluster/cli.sh ssh "$node" sudo docker rmi "$image_name" || : | ||
kcmd cluster/cli.sh ssh "$node" sudo docker pull "$image_name" | ||
done | ||
} | ||
|
||
get_public_port() { | ||
local provider="${KUBEVIRT_PROVIDER:?Please export KUBEVIRT_PROVIDER variable}" | ||
local private_port="${1:?}" | ||
local socket | ||
|
||
socket="$(docker port "${provider}-dnsmasq" "$private_port")" | ||
|
||
echo "${socket##*:}" | ||
} | ||
|
||
_kubectl() { | ||
kcmd cluster/kubectl.sh "$@" | ||
} | ||
|
||
run_apb() { | ||
local tempfile && tempfile="$(mktemp)" | ||
|
||
sed \ | ||
-e 's/docker.io/registry:5000/g' \ | ||
-e 's/ansibleplaybookbundle/kubevirt-apb/g' \ | ||
templates/kubevirt-apb.yml \ | ||
> "$tempfile" | ||
|
||
_kubectl create -f "$tempfile" | ||
} | ||
|
||
get_kubevirt() { | ||
local kubevirt_tag="v0.7.0-alpha.5" | ||
local kubevirt_repo_url="https://github.com/kubevirt/kubevirt.git" | ||
readonly KUBEVIRT_REPO_PATH="$(mktemp -dt kubevirt.XXX)" | ||
|
||
git clone "$kubevirt_repo_url" "$KUBEVIRT_REPO_PATH" | ||
kcmd git checkout "$kubevirt_tag" | ||
} | ||
|
||
main() { | ||
[[ "$KUBEVIRT_REPO_PATH" ]] || get_kubevirt | ||
cluster_up | ||
trap "cluster_down" EXIT | ||
cluster_sync | ||
run_apb | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be good also run deprovisioning, I saw it broken many times too. Then you need to wait until kubevirt serviceinstance disappear from cluster and there are no kubevirt pods. |
||
} | ||
|
||
[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serviceinstance can end up in several states, I usually wait until
status.provisionStatus == Provisioned
with commandoc get serviceinstances -n kube-system kubevirt -o template --template "{{.status.provisionStatus}}"
and then if this works it doesn't mean that all went good ... I already saw it several times that all tasks were skip and APB just did nothing successfully :-/ ...
The easiest sanity is probably checking version of kubevirt via API
curl -X GET -H "Authorization: Bearer $(oc whoami -t)" -k https://localhost:8443/apis/subresources.kubevirt.io/v1alpha2/version