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

feat: add terraform code for testing purpose #24

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

passionne
Copy link
Contributor

This is a work in progress PR

The goal is to provide terraform code which trigger a VM
and make any test of RPM installation or upgrade easier.

@passionne passionne requested review from a team April 10, 2024 07:10
@passionne passionne force-pushed the feat/add_terraform_code_for_testing_purpose branch from 33620b1 to 79f7d1e Compare July 24, 2024 20:53
passionne added a commit that referenced this pull request Jul 31, 2024
How to test the fix:

Using the terraform code from PR
#24:

* build local RPMs for two versions:

----
cd apim/4.x/
mkdir -p rpms/4.{3.1,4.3}
./build.sh -v 4.3.1
rm graviteeio-apim-4x-4.3.1-1.noarch.rpm
mv *.rpm rpms/4.3.1/
./build.sh -v 4.4.3
rm graviteeio-apim-4x-4.4.3-1.noarch.rpm
mv *.rpm rpms/4.4.3/
----

* then run a redhat 9 VM in Azure:

----
cd ../../test/terraform_linux_vm/redhat
export TF_VAR_allowed_ips="$(curl -s 'https://ipv4.seeip.org')"
export TF_VAR_username=graviteeio
terraform apply -auto-approve
----

* copy your local RPMs to the remote machine following connexion instruction as output from terraform

----
scp ... -r ../../../apim/4.x/rpms graviteeio@<VM ip>:.
----

* connect to the VM with ssh following instruction from terraform output and get into current tmux session

----
ssh .... graviteeio@<VM ip>
tmux attach
----

* install first version of built RPMs:

----
./install_redhat_graviteeio.sh install_graviteeio_from_local_rpms rpms/4.3.1/
----

* check that APIM works as expected:
** from the remote machine via ./install_redhat_graviteeio.sh test_graviteeio
** by using SSH tunnet from your browser in http://localhost:8084/ for the console (user/pass == admin/admin) and to the portal with http://localhost:8085/
* do the upgrade in VM:

----
for rpm in rpms/4.4.3/*.rpm; do sudo yum upgrade -y "${rpm}"; done
sudo systemctl daemon-reload
sudo systemctl restart graviteeio-apim-gateway graviteeio-apim-rest-api
sleep 45 #wait backend start
sudo systemctl restart nginx
----

* check again that console and portal continue to work as expected.

Note, the reproduce the issue, rather than local RPM install, do:

----
./install_redhat_graviteeio.sh install_graviteeio_from_repository 4.3.1
----

check all good and then:

----
sudo yum upgrade -y "graviteeio-apim-4x-4.4.3"
sudo systemctl daemon-reload
sudo systemctl restart graviteeio-apim-gateway graviteeio-apim-rest-api
sleep 45 #wait backend start
sudo systemctl restart nginx
----

Now console still works, but portal is broken.

TT-4996
APIM-6148
passionne added a commit that referenced this pull request Aug 1, 2024
How to test the fix:

Using the terraform code from PR
#24:

* build local RPMs for two versions:

----
cd apim/4.x/
mkdir -p rpms/4.{3.1,4.3}
./build.sh -v 4.3.1
rm graviteeio-apim-4x-4.3.1-1.noarch.rpm
mv *.rpm rpms/4.3.1/
./build.sh -v 4.4.3
rm graviteeio-apim-4x-4.4.3-1.noarch.rpm
mv *.rpm rpms/4.4.3/
----

* then run a redhat 9 VM in Azure:

----
cd ../../test/terraform_linux_vm/redhat
export TF_VAR_allowed_ips="$(curl -s 'https://ipv4.seeip.org')"
export TF_VAR_username=graviteeio
terraform apply -auto-approve
----

* copy your local RPMs to the remote machine following connexion instruction as output from terraform

----
scp ... -r ../../../apim/4.x/rpms graviteeio@<VM ip>:.
----

* connect to the VM with ssh following instruction from terraform output and get into current tmux session

----
ssh .... graviteeio@<VM ip>
tmux attach
----

* install first version of built RPMs:

----
./install_redhat_graviteeio.sh install_graviteeio_from_local_rpms rpms/4.3.1/
----

* check that APIM works as expected:
** from the remote machine via ./install_redhat_graviteeio.sh test_graviteeio
** by using SSH tunnet from your browser in http://localhost:8084/ for the console (user/pass == admin/admin) and to the portal with http://localhost:8085/
* do the upgrade in VM:

----
for rpm in rpms/4.4.3/*.rpm; do sudo yum upgrade -y "${rpm}"; done
sudo systemctl daemon-reload
sudo systemctl restart graviteeio-apim-gateway graviteeio-apim-rest-api
sleep 45 #wait backend start
sudo systemctl restart nginx
----

* check again that console and portal continue to work as expected.

Note, the reproduce the issue, rather than local RPM install, do:

----
./install_redhat_graviteeio.sh install_graviteeio_from_repository 4.3.1
----

check all good and then:

----
sudo yum upgrade -y "graviteeio-apim-4x-4.4.3"
sudo systemctl daemon-reload
sudo systemctl restart graviteeio-apim-gateway graviteeio-apim-rest-api
sleep 45 #wait backend start
sudo systemctl restart nginx
----

Now console still works, but portal is broken.

TT-4996
APIM-6148
@passionne passionne force-pushed the feat/add_terraform_code_for_testing_purpose branch from 79f7d1e to 9da3860 Compare November 20, 2024 15:22
sudo sed -i "/\"baseURL\": /{s#\"baseURL\": \".*\"#\"baseURL\": \"http://${public_ip}:8083/portal\"#}" /opt/graviteeio/apim/portal-ui/assets/config.json
}

install_graviteeio_from_repository(){
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you should also implement upgrade? I had to manually run sudo systemctl restart graviteeio-apim-gateway graviteeio-apim-rest-api to apply upgrade after I run install_graviteeio_from_repository with the new version. Not sure about UI though I only restarted BE services

* create a VM with OS:
** RedHat 8/9
** Centos Stream 9
** Centos 7
** Suze
* can be accessible only from our IP on SSH port (22)
* ephemeral SSH key was generated
* with included script to make multiple installation easier:
** install all gravitee prerequisites (java, mongo, elastic)
** install all gravitee from artifact hub repo with specific version
** install all gravitee from built RPMs
** configure everything to make it works by default from SSH tunnel
* install script is enforced and can be used for non regression test

TODO to improve: @see todo section in documentation.
* fix rpm hook script and cleanup
+ backward compatibility of version detection

APIM-7660
APIM-4892
TT-6090
TT-6333
* align nginx configuration with what is it use in dockerized
  environment.
* process 404 error pages

APIM-8401
TT-4746
@passionne passionne force-pushed the feat/add_terraform_code_for_testing_purpose branch from 8c0e4cc to 8ff2c71 Compare January 21, 2025 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants