Skip to content
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

POC of Sending Eiffel Events within Nordix (#190-community) #88

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ on:
- master

env:
NAMESPACE: ci-eiffel
DOMAIN: eiffel4eiffel.nordix.org
NAMESPACE: eiffel
TARGET: Kubernetes
BUNDLE: Eiffel
PATH_TO_BUNDLE: ./bundles
READY_POD_TIMEOUT: 120s

jobs:
Expand All @@ -31,7 +34,7 @@ jobs:
kubectl create ns $NAMESPACE

: # Install the BUNDLE via easy2use
./easy2use start -t Kubernetes -d cluster.local -e ./bundles -n $NAMESPACE $BUNDLE -y
./easy2use start -t $TARGET -d $DOMAIN -e $PATH_TO_BUNDLE -n $NAMESPACE $BUNDLE -y

: # Wait until all pods are running
kubectl wait pod \
Expand All @@ -53,12 +56,44 @@ jobs:
kubectl get pods -n $NAMESPACE
kubectl get ingress -n $NAMESPACE

: # Wait for a while
echo "Waiting..." && sleep 30

- name: Get the EI-frontend subscriptions
run: |
cd ./utilities/eiffel && \
bash ei_subscriptions.bash -d $DOMAIN -n $NAMESPACE

- name: POST an Eiffel ArtC event
run: |
cd ./utilities/eiffel && \
bash remrem_publish_event.bash -d $DOMAIN -n $NAMESPACE

: # Wait for a while until the processing of the events
echo "Waiting..." && sleep 60

- name: Ensure that Jenkins jobs executed successfully
run: |
: # The ArtC event should trigger three different jobs.
: # ei-artifact-triggered-job, ei-artifact-triggered-parameterized-job
: # and event-triggered-job
cd ./utilities/eiffel && \
output=$(bash er_events.bash -d $DOMAIN -n $NAMESPACE -l 8 | bash jq_query.bash | wc -l)
echo "Output: ${output}"

if [ $output -eq 3 ];
then
echo "Jenkins jobs passed."
else
echo "Jenkins jobs failed." && exit 1
fi

- name: Remove Easy2Use from cluster
id: removal
if: always()
run: |
: # Remove the BUNDLE from the cluster via easy2use
./easy2use remove -t Kubernetes -d cluster.local -e ./bundles -n $NAMESPACE $BUNDLE -y
./easy2use remove -t $TARGET -d $DOMAIN -e $PATH_TO_BUNDLE -n $NAMESPACE $BUNDLE -y

: # Delete the NAMESPACE
kubectl delete ns $NAMESPACE
46 changes: 46 additions & 0 deletions utilities/eiffel/ei_subscriptions.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#
# Copyright 2024 Ericsson AB.
# For a full list of individual contributors, please see the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Get the flag values
echo -e "----------------------"
echo "Configuration settings"
echo -e "----------------------\n"
while getopts ":d:n:" opt; do
case $opt in
d)
echo "Eiffel domain: $OPTARG" >&2
EIFFEL_DOMAIN="$OPTARG"
;;
n)
echo "Namespace: $OPTARG" >&2
EIFFEL_NAMESPACE="$OPTARG"
;;
\?)
echo "Invalid flag: -$OPTARG" >&2
exit 1
;;
:) echo "Flag -$OPTARG requires an argument." >&2
exit 1
;;
esac
done

# cURL request
echo -e "\n--------------------"
echo "GET EI Subscriptions"
echo -e "--------------------\n"
curl -X GET -H "Content-type: application/json" "http://eiffel-frontend-${EIFFEL_NAMESPACE}.${EIFFEL_DOMAIN}:80/subscriptions"
42 changes: 42 additions & 0 deletions utilities/eiffel/er_events.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright 2024 Ericsson AB.
# For a full list of individual contributors, please see the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Get the flags
while getopts ":d:n:l:" opt; do
case $opt in
d)
EIFFEL_DOMAIN="$OPTARG"
;;
n)
EIFFEL_NAMESPACE="$OPTARG"
;;
l)
LIMIT="$OPTARG"
;;
\?)
echo "Invalid flag: -$OPTARG" >&2
exit 1
;;
:) echo "Flag -$OPTARG requires an argument." >&2
exit 1
;;
esac
done

# cURL request
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d 'db.events.find({})' \
"http://eiffel-er-${EIFFEL_NAMESPACE}.${EIFFEL_DOMAIN}:80/datastore/query?pageNo=1&pageSize=${LIMIT}&pageStartTime=1"
19 changes: 19 additions & 0 deletions utilities/eiffel/jq_query.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright 2024 Ericsson AB.
# For a full list of individual contributors, please see the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# JQ command
jq -r '[.items] | .[0] | .[] | select(.meta.type=="EiffelActivityFinishedEvent") | select(.data.outcome.conclusion=="SUCCESSFUL") | length'
59 changes: 59 additions & 0 deletions utilities/eiffel/remrem_publish_event.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Copyright 2024 Ericsson AB.
# For a full list of individual contributors, please see the commit history.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Get the flag values
echo -e "----------------------"
echo "Configuration settings"
echo -e "----------------------\n"
while getopts ":d:n:" opt; do
case $opt in
d)
echo "Eiffel domain: $OPTARG" >&2
EIFFEL_DOMAIN="$OPTARG"
;;
n)
echo "Namespace: $OPTARG" >&2
EIFFEL_NAMESPACE="$OPTARG"
;;
\?)
echo "Invalid flag: -$OPTARG" >&2
exit 1
;;
:) echo "Flag -$OPTARG requires an argument." >&2
exit 1
;;
esac
done

# cURL request
echo -e "\n-----------------"
echo "POST Eiffel ArtC Event"
echo -e "-----------------\n"
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{
"meta": {
"type": "EiffelArtifactCreatedEvent",
"version": "3.0.0",
"time": 1234567890,
"id": "77a7f4e7-9847-44a6-9bf0-3a19a9528ccd",
"source": {
"serializer": "pkg:maven/com.mycompany.tools/eiffel-serializer%401.0.3"
}
},
"data": {
"identity": "pkg:maven/com.othercompany.library/required@required"
}
}' "http://eiffel-remrem-publish-${EIFFEL_NAMESPACE}.${EIFFEL_DOMAIN}:80/producer/msg?mp=eiffelsemantics"
Loading