Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.
Open
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
85 changes: 85 additions & 0 deletions containers/react-native/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
FROM circleci/android:api-29-node

USER root

RUN apt update \
&& apt install gradle

# setup RH internal npm nexus registry

ADD https://password.corp.redhat.com/RH-IT-Root-CA.crt /RH-IT-Root-CA.crt

RUN chmod +r /RH-IT-Root-CA.crt

RUN npm config set -g cafile /RH-IT-Root-CA.crt

RUN npm config set -g registry https://repository.engineering.redhat.com/nexus/repository/registry.npmjs.org

# install oc cli tool

ADD https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz $HOME/oc.tar.gz

# ADD https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/macosx/oc.tar.gz $HOME/oc.tar.gz

RUN tar -xvf $HOME/oc.tar.gz

RUN mv oc /usr/local/bin/

# install watchman

ADD https://github.com/facebook/watchman/releases/download/v2020.09.21.00/watchman-v2020.09.21.00-linux.zip $HOME/watchman.zip

RUN unzip $HOME/watchman.zip

RUN mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman
RUN cp watchman-v2020.09.21.00-linux/bin/* /usr/local/bin
RUN cp watchman-v2020.09.21.00-linux/lib/* /usr/local/lib
RUN chmod 755 /usr/local/bin/watchman
RUN chmod 2777 /usr/local/var/run/watchman

# create jenkins user

RUN npm install -g react-native

RUN npm install -g detox-cli

RUN useradd -m -u 1001 jenkins

ENV HOME=/home/jenkins

RUN echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/00-local-userns.conf

RUN service procps restart


# Git clone

#RUN git clone https://github.com/aerogear/unifiedpush-cookbook.git $HOME/unifiedpush-cookbook
#RUN cd $HOME/unifiedpush-cookbook/react-native/push
#COPY ./google-services.json $HOME/unifiedpush-cookbook/react-native/push/android/app/
#COPY ./push-config.json $HOME/unifiedpush-cookbook/react-native/push/

# Android sdkmanager doesn't work with java 11 - workaround

RUN mkdir $ANDROID_HOME/tools/jaxb_lib
RUN wget https://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar -O $ANDROID_HOME/tools/jaxb_lib/activation.jar
RUN wget https://repo1.maven.org/maven2/com/sun/xml/bind/jaxb-impl/2.3.3/jaxb-impl-2.3.3.jar -O $ANDROID_HOME/tools/jaxb_lib/jaxb-impl.jar
RUN wget https://repo1.maven.org/maven2/com/sun/istack/istack-commons-runtime/3.0.11/istack-commons-runtime-3.0.11.jar -O $ANDROID_HOME/tools/jaxb_lib/istack-commons-runtime.jar
RUN wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-xjc/2.3.3/jaxb-xjc-2.3.3.jar -O $ANDROID_HOME/tools/jaxb_lib/jaxb-xjc.jar
RUN wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-core/2.3.0.1/jaxb-core-2.3.0.1.jar -O $ANDROID_HOME/tools/jaxb_lib/jaxb-core.jar
RUN wget https://repo1.maven.org/maven2/org/glassfish/jaxb/jaxb-jxc/2.3.3/jaxb-jxc-2.3.3.jar -O $ANDROID_HOME/tools/jaxb_lib/jaxb-jxc.jar
RUN wget https://repo1.maven.org/maven2/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar -O $ANDROID_HOME/tools/jaxb_lib/jaxb-api.jar
# Append jaxb_lib to the CLASSPATH in sdkmanager and avdmanager
RUN sed -ie 's%^CLASSPATH=.*%\0:$APP_HOME/jaxb_lib/*%' $ANDROID_HOME/tools/bin/sdkmanager $ANDROID_HOME/tools/bin/avdmanager

RUN $ANDROID_HOME/tools/bin/sdkmanager --update
RUN $ANDROID_HOME/tools/bin/sdkmanager --install emulator
RUN $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-28"
RUN $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-29;google_apis_playstore;x86"

USER jenkins

RUN $ANDROID_HOME/tools/bin/avdmanager create avd -n Pixel_4_API_29 -d pixel --package "system-images;android-29;google_apis_playstore;x86"
# Headless emulator run - $ANDROID_HOME/emulator/emulator -verbose -no-window -no-audio -gpu swiftshader_indirect @Pixel_4_API_29 &


79 changes: 79 additions & 0 deletions react-native/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Expected parameters for the pipeline:
// - OPENSHIFT_URL - RHMI cluster to target (https://...)
// - OPENSHIFT_USERNAME - Evals username
// - OPENSHIFT_PASSWORD - Evals user password
// - OPENSHIFT_KUBEADMIN_USERNAME - RHMI cluster-admin username
// - OPENSHIFT_KUBEADMIN_PASSWORD - RHMI cluster-admin password
// - FIREBASE_SERVER_KEY - FCM server key
// - FIREBASE_SENDER_ID - FCM sender ID

pipeline {
agent {
label 'osx'
}
options {
timestamps()
ansiColor('gnome-terminal')
}
environment {
FIREBASE_SERVER_KEY = credentials('reactnative-firebase-server-key')
FIREBASE_SENDER_ID = credentials('reactnative-firebase-sender-id')
GOOGLE_SERVICES = credentials('reactnative-google-services')
JUNIT_REPORT_STACK = '1'
}
stages {
stage('Setup'){
stages{
stage('Prepare'){
steps{
dir('react-native'){
wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[var: 'OPENSHIFT_KUBEADMIN_PASSWORD', password: OPENSHIFT_KUBEADMIN_PASSWORD]]]) {
sh "oc login $OPENSHIFT_URL -u $OPENSHIFT_KUBEADMIN_USERNAME -p ${OPENSHIFT_KUBEADMIN_PASSWORD}"
}
sh """
yarn install
./scripts/prepare.js
"""
}
}
}
stage('Git clone'){
steps{
dir('react-native') {
sh """
git clone https://github.com/mmusil/unifiedpush-cookbook.git ./unifiedpush-cookbook
cd unifiedpush-cookbook
git checkout -b E2E_testing origin/E2E_testing
"""
}
}
}
stage('Build Testing App') {
steps {
dir('react-native/unifiedpush-cookbook/react-native/push') {
sh """
cp ${GOOGLE_SERVICES} ./android/app/google-services.json
cp ../../../fixtures/push-config.json ./
yarn install
detox build --configuration android.release
"""
}
}
}
}
}
stage('Testing') {
stages {
stage('Test android') {
steps {
dir('react-native/unifiedpush-cookbook/react-native/push') {
sh """
detox test -H --configuration android.release --cleanup --loglevel info
"""
}
}
}
}
}
}
}
59 changes: 59 additions & 0 deletions react-native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# AeroGear Integration Tests

## Prerequisites

#### Firebase Account

Login to Firebase, create a new project and app, download the `google-services.json` and copy it to `fixtures/`, and export the server key and sender id.

```
cp ~/Downloads/google-services.json fixtures/
```

```bash
export FIREBASE_SERVER_KEY=[..]
export FIREBASE_SENDER_ID=[..]
```

## Install dependencies

```
npm install
```

## Services

Tests can target OpenShift instance with RHMI.

To target OpenShift instance run:

```
oc login ... (kubeadmin user)

export OPENSHIFT_URL= (cluster URL)
export OPENSHIFT_USERNAME= (customer-admin user)
export OPENSHIFT_PASSWORD= (customer-admin password)

cd .. && npm install && cd react-native
./scripts/prepare.js

oc login ... (kubeadmin user)
```

## Setup push config

```
./scripts/prepare.js
```

## Run the tests

You can run the app in debug or release mode. For CI, it's recommended to use release mode,
because of problems with running js server for react-native in the background.
Configuration names are `android.debug` or `android.release`.

```
detox build --configuration <configuration-name>
```

To run the tests in headless mode, add `-H` argument.
77 changes: 77 additions & 0 deletions react-native/fixtures/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"project_info": {
"project_number": "231641968159",
"firebase_url": "https://push-test-reactnative.firebaseio.com",
"project_id": "push-test-reactnative",
"storage_bucket": "push-test-reactnative.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:231641968159:android:484c101a33f23550ebaf2a",
"android_client_info": {
"package_name": "com.push"
}
},
"oauth_client": [
{
"client_id": "231641968159-36lvsncmh0uh1sn2qni81ugmo8thepq9.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBuulcxxgIyr2v1tJaTWpVkQFbTsZY9-YY"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "231641968159-36lvsncmh0uh1sn2qni81ugmo8thepq9.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:231641968159:android:c813a6054850a57eebaf2a",
"android_client_info": {
"package_name": "com.push.rn"
}
},
"oauth_client": [
{
"client_id": "231641968159-jqb4s3thid4teid421bi25mimbpaicmk.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.push.rn",
"certificate_hash": "5e8f16062ea3cd2c4a0d547876baa6f38cabf625"
}
},
{
"client_id": "231641968159-36lvsncmh0uh1sn2qni81ugmo8thepq9.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBuulcxxgIyr2v1tJaTWpVkQFbTsZY9-YY"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "231641968159-36lvsncmh0uh1sn2qni81ugmo8thepq9.apps.googleusercontent.com",
"client_type": 3
}
]
}
}
}
],
"configuration_version": "1"
}
8 changes: 8 additions & 0 deletions react-native/fixtures/push-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"pushServerURL": "http://unifiedpush-configurable-container-mmusil-test-push-latesttag.apps.helios.intlyqe.com",
"android": {
"senderID": "231641968159",
"variantID": "8db2c0c8-2623-4e50-82da-4a22ed2c31f7",
"variantSecret": "7a2188b2-1c44-4041-b6d5-0f6334befac1"
}
}
14 changes: 14 additions & 0 deletions react-native/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "aerogear-push-e2e-tests",
"version": "1.0.0",
"private": true,
"description": "AeroGear Push E2E test fro react-native client",
"main": "index.js",
"scripts": {
"prestart": "./scripts/start-bs-local.sh",
"start": ". ./scripts/setup-env-vars.sh && mocha"
},
"dependencies": {
"axios": "0.21.1"
}
}
36 changes: 36 additions & 0 deletions react-native/scripts/build-testing-app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

set -e

if [ ! -d "./unifiedpush-cookbook" ]; then
git clone https://github.com/mmusil/unifiedpush-cookbook.git
git ch -b E2E_testing origin/E2E_testing
fi

cp fixtures/push-config.json unifiedpush-cookbook/react-native/push

# cp -R fixtures/fastlane/* unifiedpush-cookbook/react-native/push

if [ "$MOBILE_PLATFORM" != "ios" ]; then
cp fixtures/google-services.json unifiedpush-cookbook/react-native/push/android/app
fi

cd unifiedpush-cookbook/react-native/push

yarn install

if [ "$MOBILE_PLATFORM" = "ios" ]; then

# build ios using xcode without certificates

else

# push tests works only on android
detox build --configuration android.release

# curl \
# -u "$BROWSERSTACK_USER:$BROWSERSTACK_KEY" \
# -X POST https://api-cloud.browserstack.com/app-automate/upload \
# -F "file=@$PWD/platforms/android/app/build/outputs/apk/debug/app-debug.apk" \
# >bs-app-url.txt
fi
Loading