Skip to content

Commit

Permalink
Merge pull request #126 from jzding/fix-e2e
Browse files Browse the repository at this point in the history
fix e2e test script
  • Loading branch information
jzding authored Jul 18, 2024
2 parents 5c5eb38 + 251c825 commit 3a50f0b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
VERSION ?=latest

PROXY_IMG ?= quay.io/redhat-cne/hw-event-proxy:$(VERSION)
SIDECAR_IMG ?= quay.io/redhat-cne/cloud-event-proxy:${VERSION}
CONSUMER_IMG ?= quay.io/redhat-cne/cloud-event-consumer:$(VERSION)
SIDECAR_IMG ?= quay.io/redhat-cne/cloud-event-proxy:release-4.14
CONSUMER_IMG ?= quay.io/redhat-cne/cloud-event-consumer:release-4.14

# For performance test with HTTP transport
NUM_CONSUMER ?=20
Expand All @@ -23,6 +23,8 @@ else
GOBIN=$(shell go env GOBIN)
endif

OS := $(shell uname -s)

kustomize:
ifeq (, $(shell which kustomize))
@{ \
Expand All @@ -47,9 +49,15 @@ check-env:

# Configure redfish credentials and BMC ip from environment variables
redfish-config:
ifeq ($(OS), Darwin)
@sed -i "" -e "s/username=.*/username=${REDFISH_USERNAME}/" ./manifests/proxy/kustomization.yaml
@sed -i "" -e "s/password=.*/password=${REDFISH_PASSWORD}/" ./manifests/proxy/kustomization.yaml
@sed -i "" -e "s/hostaddr=.*/hostaddr=${REDFISH_HOSTADDR}/" ./manifests/proxy/kustomization.yaml
else
@sed -i -e "s/username=.*/username=${REDFISH_USERNAME}/" ./manifests/proxy/kustomization.yaml
@sed -i -e "s/password=.*/password=${REDFISH_PASSWORD}/" ./manifests/proxy/kustomization.yaml
@sed -i -e "s/hostaddr=.*/hostaddr=${REDFISH_HOSTADDR}/" ./manifests/proxy/kustomization.yaml
endif

# label the first Ready worker node as local
label-node:
Expand Down
18 changes: 10 additions & 8 deletions e2e-tests/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,16 @@ fi

# number of additional consumers need to deploy/undeploy
NUM_OF_CONSUMER=`expr $n_consumer - 1`
for i in `seq $NUM_OF_CONSUMER`
do
wait_for_resource deployment/consumer-$i available 60s >/dev/null 2>&1
if [[ $job_result -eq 1 ]]; then
echo "Consumer-$i pod is not available"
exit 1
fi
done
if [[ $NUM_OF_CONSUMER -gt 0 ]]; then
for i in `seq $NUM_OF_CONSUMER`
do
wait_for_resource deployment/consumer-$i available 60s >/dev/null 2>&1
if [[ $job_result -eq 1 ]]; then
echo "Consumer-$i pod is not available"
exit 1
fi
done
fi

# uncomment this when debugging image issues in a ci job
# check_images
Expand Down
13 changes: 7 additions & 6 deletions e2e-tests/scripts/verify-sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def main():

with open(consumer_log_file, 'r') as f:
for event_received in f:
event_received = event_received.replace("\\\"", "\"")
match_found = True
for k, v in event_expected.items():
if k in fields_to_verify and compare(event_received, k, v) != 0:
Expand All @@ -37,21 +38,21 @@ def main():
sys.exit(0)
print("Match not found for {}".format(event_data_file))
sys.exit(1)


def compare(received, k, expected):
pattern = None
if k == 'MessageArgs':
pattern = ',\\\\"{}\\\\":\[\\\\"(.*?)\\\\"\]'.format(k)
pattern = r',\"{}\":\[\"(.*?)\"\]'.format(k)
else:
pattern = ',\\\\"{}\\\\":\\\\"(.*?)\\\\"'.format(k)
pattern = r',\"{}\":\"(.*?)\"'.format(k)
m = re.search(pattern, received)
if not m:
logging.debug("key %s not found. Pattern used: %s", k, pattern)
logging.debug("key %s not found. Pattern used: %s, received: %s, expected: %s", k, pattern, received, expected)
return -1
actual = m.group(1)
if k == 'MessageArgs':
args = actual.split('\\",\\"')
args = actual.split('\",\"')
if set(args) != set(expected):
logging.debug("key: %s, expected: %s, actual: %s", k, expected, args)
return -1
Expand All @@ -61,4 +62,4 @@ def compare(received, k, expected):
return 0

if __name__ == '__main__':
main()
main()
4 changes: 2 additions & 2 deletions manifests/consumer/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resources:
images:
- name: cloud-event-consumer
newName: quay.io/redhat-cne/cloud-event-consumer
newTag: latest
newTag: release-4.14
- name: cloud-event-sidecar
newName: quay.io/redhat-cne/cloud-event-proxy
newTag: latest
newTag: release-4.14
5 changes: 3 additions & 2 deletions manifests/proxy/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ replicas:
name: hw-event-proxy
secretGenerator:
- literals:
# replace these with real info from your baremetal device
- username=root
- password=calvin
- hostaddr=10.16.230.6
- hostaddr=192.0.2.1
name: redfish-basic-auth
type: Opaque
images:
- name: cloud-event-sidecar
newName: quay.io/redhat-cne/cloud-event-proxy
newTag: latest
newTag: release-4.14
- name: hw-event-proxy
newName: quay.io/redhat-cne/hw-event-proxy
newTag: latest

0 comments on commit 3a50f0b

Please sign in to comment.