Bridge Integ Test Machine
Bridge has an EC2 machine for manually running integ tests. The reasons we want an EC2 machine is because running it on a laptop takes too much CPU and memory, which slows down integ tests and prevents doing any other work on that laptop.
This is a temporary solution specifically intended to workaround Jenkins being defunct. There is long-term unscheduled work to find a proper CI/CD solution to replace this. That work is not covered in this document.
Setup Integ Test Machine
These are instructions for how to set up the Integ Test EC2 machine. You shouldn’t have to follow these instructions, unless for whatever reason that EC2 machine needs to be replaced.
Log into AWS and navigate to the EC2 dashboard.
Click Instances on the left nav bar, then click Launch Instances on the top right. Create a host with the following:
Name: Something descriptive like bridge-integ-test
AMI: Amazon Linux 2023
Architecture: 64-bit (Arm) - We want Arm so we can use AWS’s newer (cheaper) hardware types.
Instance Type: t4g.medium - We chose medium because the old Jenkins machine was a medium. We might be able to get away with a small, but the difference is ~$25/mo vs $12.5/mo.
Key Pair: bridge-integ-test.pem
VPC: vpc-e9335a92 (bridge-aux)
Auto-assign public IP: Enable
Firewall (security groups): Select existing security group → bridge-aux-VpnSecurityGroup-8CNS9SY6YHNY
Once the new instance is up and running, SSH into the Integ Test Machine as per the instructions below.
Bridge Server and Worker require Java 8. Install Amazon’s Java 8 JDK (Corretto) by running
sudo yum install java-1.8.0-amazon-corretto-devel.Install Git, using
sudo yum install git.Install Maven, using
sudo yum install maven-amazon-corretto8.In your home directory, create
.aws/configwith the following content:[default] region=us-east-1In your home directory, create a
gitdirectory. In that directory, rungit clone https://github.com/Sage-Bionetworks/BridgeIntegrationTests.gitandgit clone https://github.com/Sage-Bionetworks/BridgeWorkerIntegrationTests.git. Since these are public repos and we are doing read-only, we don’t need login credentials.In your home directory, create the file
bridge-sdk.propertieswith the following content:env = develop app.identifier = apiGo to LastPass and search for bridge-integ-test bridge-sdk-test.properties. Copy this file to the home directory in the Integ Test Machine. (The easiest way to do this is to use vi on the Integ Test Machine and then copy-paste the file into vi.)
Do the same for bridge-integ-test BridgeWorker-test.conf.
Back in your home directory, create a
logdirectory. This will be where our integ test logs are going.
SSHing into the Integ Test Machine
Log into AWS and navigate to the EC2 dashboard.
Click on Instances in the left nav bar, and select the bridge-integ-test instance. Note the Public IPv4 DNS (should be something like
ec2-3-92-255-6.compute-1.amazonaws.com).Go to LastPass and download bridge-integ-test.pem. Make sure to
chmod 600 bridge-integ-test.pemto ensure permissions are being set correctly.On your laptop, open (or create)
.ssh/configwith the following. There can be multiple entries if this file already exists. Substitute the host name you copied down above.Host bridge-integ-test HostName ec2-3-92-255-6.compute-1.amazonaws.com IdentityFile ~/bridge-integ-test.pem User ec2-userLog into Sage VPN.
Now you can simply run
ssh bridge-integ-test.
Running Integ Tests
SSH into the Integ Test Machine as per above.
Edit
bridge-sdk.properties,bridge-sdk-test.properties, andBridgeWorker-test.conf. For Worker Integ Tests, you’ll need to update all 3 files. For Server Integ Tests, you only need to update the first 2.The simplest way is to use vi.
In
bridge-sdk.properties, at the top of the file is theenvproperty. Set this todeveloporstagingorproductionaccordingly.In
BridgeWorker-test.conf, at the top of the file is thebridge.envproperty. Set this todevoruataccordingly. (Note, Worker Integ Tests don’t run Note, this is different frombridge-sdk.properties. Both are needed for Worker Integ Tests.)Note:
bridge-sdk-test.propertiesdoesn’t have an env property.Also, uncomment the properties for env you want to test. Comment out the properties for the envs you aren’t testing.
cd into the directory of the test you want to run (
git/BridgeIntegrationTestsorgit/BridgeWorkerIntegrationTests).git pullto update the integ tests.git log --onelineto verify that the changes you pulled are the ones you expected.Run
mvn -U clean test -e &> ~/log/server-dev-yyyy-mm-dd-hhmm.log &.IMPORTANT: If running production tests, run this instead:
mvn -U clean test -DjunitCategory=integrationSmokeTests -e &> ~/log/server-prod-yyyy-mm-dd-hhmm.log &. Some tests cannot be run in production, and this ensures that only our smoke tests are run. (Worker Integ Tests do not run at all in Production.)Note: UploadTest testRedriveUploadSmallBatch() and testRedriveUploadLargeBatch() don’t succeed in Prod. This never succeeded in Prod, because it uses Superadmin API, and we don’t have Superadmin credentials in our Integ Test Machine. We should change this to not run in Prod.
The
-Umakes sure we update all packages in our Maven package cache. Running without this flag has led to weird dependency issues in the past.cleanensures we have a clean workspace before running tests.-ealso produces error messages.&>sends both stdout and stderr to the specified file.Name the log file according to your stack (server or worker), env (dev, uat, or prod), and set the timestamp accordingly. This is to disambiguate between test runs.
&runs Maven in a separate process, so that if the SSH session dies, Maven still continues to run our integ tests.
Server tests take about 37 min in Dev and Staging, 8 min for Prod. Worker tests take about 15 minutes.