Skip to content

Commit

Permalink
feat: Add ci tests to validate PR changes (keploy#1176)
Browse files Browse the repository at this point in the history
* feat: added ci pipelline for testing gin-mongo

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated location of the app

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated keploy location

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated test command

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated keploy location

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updateed location

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed eec

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the pid mechanism

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated kill mechanism]

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed sudo error

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: made async

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: increased wait time

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added mongo

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed keploy network

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: inc sleep time

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: changed the branch

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed branch issues

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the time

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the tijme

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking if the application started or not

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added support for timestamp

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed status

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed echo

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: checking python workflow

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: installed virtualenv before pushing

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added code to start keploy

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed sed

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed sed

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: udpated keploy binary

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated keploy location

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the repo

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added migrations

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added sleep time

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated back to keploy

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed virtualenv

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: check the containers

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the config

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added back keploy

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed keploy

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: changed to fork

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: now checking the logs

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking on a diff portr

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: just checking the logs now

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added keploy back

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: not checking the logs

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking if something is running on the port or not

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking with telnet

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: s

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: somethign

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: as

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: asd

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: asd

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated endpoint

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed telnet

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed migrations

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: changed starting of databse

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: starting the server again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking docker containers

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added back pid

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added the logic for test

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added backward compatibility to the testcases

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removing keploy now

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added pipeline for node

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated workflow file

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the docker container

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added java linux workflow

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated location of the script

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking java version

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated java version

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updating apt

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: just checking the application

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking the installed java versions

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking the directories

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated java version

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: starting with keploy now

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated keploy location

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added 2 extra steps

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed indentation issues

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the workflow

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added update script

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updating the java version again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added the code for keploy test mode as well

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: just confirming where we are

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the location of the script

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: increased the delay

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking the testcases

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed location

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added postgres

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: running in detached mode

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: running in detached mode

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added java with docker

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: changed to java docker

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added code to expand aliases

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: stopped using aliases

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed keploy alias

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: starting keploy network

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed detached mode

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed interactiveness of the shell

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed Home

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added support for golang docker

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed using keplopy binary

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated the command to start the applciation

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checming

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking if the file already exists or not

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: sending y

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removing keploy-config before

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: not checking out to a diff branch

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: building docker

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: stopping keploy differently

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed test mode

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removing ginapp

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added support for python docker

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed it

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: specifying host

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking logs

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking the logs again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking logs again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: switched docker network

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: not creating database

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated docker run command

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: comment added

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removed migrations

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added initialisation script

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: made the path absolute

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: absolute path

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: inspecting the network

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: using docker ps

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: ps again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking logs

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checkj

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: running detached again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed test

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removing old keploy

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: stopping before removing

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: using rm -f

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: inc delay

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: added node docker

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: not using binary anymore

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: removing preexisting testcases

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: inc the delay

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking logs

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: check

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: check

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: check

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: check

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: only testing binaries

Signed-off-by: Pranshu Srivastava <[email protected]>

* feat: added for loop

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: using binary now

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking both the results

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: checking update

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: reverted some changes

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: waiting before next iteration

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated java

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated go branch

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: fixed location of script

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated again

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated python branch

Signed-off-by: Pranshu Srivastava <[email protected]>

* fix: updated repo

Signed-off-by: Pranshu Srivastava <[email protected]>

---------

Signed-off-by: Pranshu Srivastava <[email protected]>
Co-authored-by: Gourav kumar <[email protected]>
Former-commit-id: 47d3de2
  • Loading branch information
PranshuSrivastava and gouravkrosx authored Dec 6, 2023
1 parent 92ad508 commit 996ba31
Show file tree
Hide file tree
Showing 11 changed files with 464 additions and 9 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/golang-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

# Checkout a different branch
git fetch origin
git checkout native-linux

# Start mongo before starting keploy.
docker run --rm -d -p27017:27017 --name mongoDb mongo

# Check if there is a keploy-config file, if there is, delete it.
if [ -f "./keploy-config.yaml" ]; then
rm ./keploy-config.yaml
fi

# Generate the keploy-config file.
./../../keployv2 generate-config

# Update the global noise to ts.
config_file="./keploy-config.yaml"
sed -i 's/"body": {}/"body": {"ts":[]}/' "$config_file"

# Remove any preexisting keploy tests and mocks.
sudo rm -rf keploy/

# Build the binary.
go build -o ginApp

for i in {1..2}; do
# Start the gin-mongo app in record mode and record testcases and mocks.
sudo -E env PATH="$PATH" ./../../keployv2 record -c "./ginApp" &

# Wait for the application to start.
app_started=false
while [ "$app_started" = false ]; do
if curl -X GET http://localhost:8080/CJBKJd92; then
app_started=true
fi
sleep 3 # wait for 3 seconds before checking again.
done

# Get the pid of the application.
pid=$(pgrep keploy)

# Start making curl calls to record the testcases and mocks.
curl --request POST \
--url http://localhost:8080/url \
--header 'content-type: application/json' \
--data '{
"url": "https://google.com"
}'

curl --request POST \
--url http://localhost:8080/url \
--header 'content-type: application/json' \
--data '{
"url": "https://facebook.com"
}'

curl -X GET http://localhost:8080/CJBKJd92

# Wait for 5 seconds for keploy to record the tcs and mocks.
sleep 5

# Stop the gin-mongo app.
sudo kill $pid

# Wait for 5 seconds for keploy to stop.
sleep 5
done

# Start the gin-mongo app in test omde.
sudo -E env PATH="$PATH" ./../../keployv2 test -c "./ginApp" --delay 7

# Get the test results from the testReport file.
report_file="./keploy/testReports/report-1.yaml"
test_status1=$(grep 'status:' "$report_file" | head -n 1 | awk '{print $2}')
report_file2="./keploy/testReports/report-2.yaml"
test_status2=$(grep 'status:' "$report_file2" | head -n 1 | awk '{print $2}')

# Return the exit code according to the status.
if [ "$test_status1" = "PASSED" ] && [ "$test_status2" = "PASSED" ]; then
exit 0
else
exit 1
fi
22 changes: 22 additions & 0 deletions .github/workflows/golang_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Golang On Linux
on: [pull_request]
jobs:
golang_linux:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build binary
run: |
go build -o keployv2
- name: Checkout the samples-go repository
uses: actions/checkout@v2
with:
repository: keploy/samples-go
path: samples-go
- name: Run samples-go application
run: |
cd samples-go/gin-mongo
source ./../../.github/workflows/golang-linux.sh
77 changes: 77 additions & 0 deletions .github/workflows/java-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#! /bin/bash

# Start postgres instance.
docker run -d -e POSTGRES_USER=petclinic -e POSTGRES_PASSWORD=petclinic -e POSTGRES_DB=petclinic -p 5432:5432 postgres:15.2

# Update the java version
source ./../../../.github/workflows/update-java.sh

# Remove any existing test and mocks by keploy.
sudo rm -rf keploy/

for i in {1..2}; do
# Start keploy in record mode.
sudo -E env PATH=$PATH ./../../../keployv2 record -c './mvnw spring-boot:run' &

# Wait for the application to start.
app_started=false
while [ "$app_started" = false ]; do
if curl -X GET http://localhost:9966/petclinic/api/pettypes; then
app_started=true
fi
sleep 3 # wait for 3 seconds before checking again.
done

# Get the pid of the application.
pid=$(pgrep keploy)

# Start making curl calls to record the testcases and mocks.
curl -X GET http://localhost:9966/petclinic/api/pettypes

curl --request POST \
--url http://localhost:9966/petclinic/api/pettypes \
--header 'content-type: application/json' \
--data '{
"name":"John Doe"}'

curl -X GET http://localhost:9966/petclinic/api/pettypes

curl --request POST \
--url http://localhost:9966/petclinic/api/pettypes \
--header 'content-type: application/json' \
--data '{
"name":"Alice Green"}'

curl -X GET http://localhost:9966/petclinic/api/pettypes

curl --request DELETE \
--url http://localhost:9966/petclinic/api/pettypes/1

curl -X GET http://localhost:9966/petclinic/api/pettypes

# Wait for 5 seconds for keploy to record the tcs and mocks.
sleep 5

# Stop keploy.
sudo kill $pid

# Wait for 5 seconds for keploy to stop.
sleep 5

done

# Start keploy in test mode.
sudo -E env PATH=$PATH ./../../../keployv2 test -c './mvnw spring-boot:run' --delay 20

# Get the test results from the testReport file.
report_file="./keploy/testReports/report-1.yaml"
test_status1=$(grep 'status:' "$report_file" | head -n 1 | awk '{print $2}')
report_file2="./keploy/testReports/report-2.yaml"
test_status2=$(grep 'status:' "$report_file2" | head -n 1 | awk '{print $2}')

# Return the exit code according to the status.
if [ "$test_status1" = "PASSED" ] && [ "$test_status2" = "PASSED" ]; then
exit 0
else
exit 1
fi
34 changes: 34 additions & 0 deletions .github/workflows/java_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Java on Linux
on: [pull_request]
jobs:
java_linux:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build Keploy binary
run: |
go build -o keployv2
- name: Checkout samples-java repository
uses: actions/checkout@v2
with:
repository: keploy/samples-java
path: samples-java

- name: Installing the necessary dependencies
run: |
cd samples-java/spring-petclinic/spring-petclinic-rest
./mvnw dependency:resolve
- name: Compile the project
run: |
cd samples-java/spring-petclinic/spring-petclinic-rest
source ./../../../.github/workflows/update-java.sh
./mvnw compile
- name: Run the spring-petclinic-rest app
run: |
cd samples-java/spring-petclinic/spring-petclinic-rest
source ./../../../.github/workflows/java-linux.sh
77 changes: 77 additions & 0 deletions .github/workflows/node-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#! /bin/bash

# Start the docker container.
sudo docker run --name mongoDb --rm -p 27017:27017 -d mongo

# Install the required node dependencies.
npm install

# Edit the connection.js file to connect to local mongodb.
file_path="src/db/connection.js"
sed -i "s/mongoDb:27017/localhost:27017/" "$file_path"

# Remove any preexisting keploy tests.
sudo rm -rf keploy/

for i in {1..2}; do
# Start keploy in record mode.
sudo -E env PATH=$PATH ./../../keployv2 record -c 'node src/app.js' &

# Wait for the application to start.
app_started=false
while [ "$app_started" = false ]; do
if curl -X GET http://localhost:8000/students; then
app_started=true
fi
sleep 3 # wait for 3 seconds before checking again.
done

# Get the pid of the application.
pid=$(pgrep keploy)

# Start making curl calls to record the testcases and mocks.
curl --request POST \
--url http://localhost:8000/students \
--header 'content-type: application/json' \
--data '{
"name":"John Do",
"email":"[email protected]",
"phone":"0123456799"
}'

curl --request POST \
--url http://localhost:8000/students \
--header 'content-type: application/json' \
--data '{
"name":"Alice Green",
"email":"[email protected]",
"phone":"3939201584"
}'

curl -X GET http://localhost:8000/students

# Wait for 5 seconds for keploy to record the tcs and mocks.
sleep 5

# Stop keploy.
sudo kill $pid

# Wait for 5 seconds for keploy to stop.
sleep 5
done

# Start keploy in test mode.
sudo -E env PATH=$PATH ./../../keployv2 test -c 'node src/app.js' --delay 10

# Get the test results from the testReport file.
report_file="./keploy/testReports/report-1.yaml"
test_status1=$(grep 'status:' "$report_file" | head -n 1 | awk '{print $2}')
report_file2="./keploy/testReports/report-2.yaml"
test_status2=$(grep 'status:' "$report_file2" | head -n 1 | awk '{print $2}')

# Return the exit code according to the status.
if [ "$test_status1" = "PASSED" ] && [ "$test_status2" = "PASSED" ]; then
exit 0
else
exit 1
fi
23 changes: 23 additions & 0 deletions .github/workflows/node_linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Node on Linux
on: [pull_request]
jobs:
node_linux:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Build Keploy binary
run: |
go build -o keployv2
- name: Checkout samples-typescript repository
uses: actions/checkout@v2
with:
repository: keploy/samples-typescript
path: samples-typescript

- name: Run the express-mongoose app
run: |
cd samples-typescript/express-mongoose
source ./../../.github/workflows/node-linux.sh
Loading

0 comments on commit 996ba31

Please sign in to comment.