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 integration test for Mobile with Patrol #2953

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
56 changes: 56 additions & 0 deletions .github/workflows/patrol-integration-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Integration tests

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

env:
JAVA_VERSION: 17
FLUTTER_VERSION: 3.22.2

jobs:
mobile_integration_test:
permissions:
contents: "read"
id-token: "write"

name: Run integration tests for mobile apps
runs-on: ubuntu-latest
concurrency:
group: ngrok
cancel-in-progress: false
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Authenticate to Google Cloud
uses: "google-github-actions/auth@v2"
with:
project_id: ${{ secrets.GOOGLE_CLOUD_PROJECT_ID }}
workload_identity_provider: ${{ secrets.GOOGLE_CLOUD_WORKLOAD_IDENTITY_PROVIDER_ID }}
service_account: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT }}
hoangdat marked this conversation as resolved.
Show resolved Hide resolved

- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v2

- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
cache: true

- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: "temurin"

- name: Run prebuild
run: ./scripts/prebuild.sh

- name: Test
env:
NGROK_AUTHTOKEN: ${{ secrets.NGROK_AUTHTOKEN }}
run: ./scripts/patrol-integration-test-with-docker.sh
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,4 @@ app.*.symbols
*.g.dart
messages_*.dart
*.mocks.dart
integration_test/test_bundle.dart
13 changes: 12 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ if (flutterVersionName == null) {

def flutterMinSdkVersion = localProperties.getProperty('flutter.minSdkVersion')
if (flutterMinSdkVersion == null) {
flutterMinSdkVersion = '19'
flutterMinSdkVersion = '21'
}

apply plugin: 'com.android.application'
Expand Down Expand Up @@ -54,6 +54,8 @@ android {
manifestPlaceholders = [
'appAuthRedirectScheme': 'teammail.mobile'
]
testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: "true"
}

compileOptions {
Expand All @@ -77,7 +79,15 @@ android {
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.release
}
debug {
minifyEnabled false
}
hoangdat marked this conversation as resolved.
Show resolved Hide resolved
}

testOptions {
execution "ANDROIDX_TEST_ORCHESTRATOR"
}

}

flutter {
Expand All @@ -90,4 +100,5 @@ dependencies {
implementation 'androidx.work:work-runtime-ktx:2.7.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'androidx.window:window:1.0.0'
androidTestUtil "androidx.test:orchestrator:1.5.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.linagora.android.tmail;

import androidx.test.platform.app.InstrumentationRegistry;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import pl.leancode.patrol.PatrolJUnitRunner;

@RunWith(Parameterized.class)
public class MainActivityTest {
@Parameters(name = "{0}")
public static Object[] testCases() {
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
// replace "MainActivity.class" with "io.flutter.embedding.android.FlutterActivity.class"
// if your AndroidManifest is using: android:name="io.flutter.embedding.android.FlutterActivity"
instrumentation.setUp(MainActivity.class);
instrumentation.waitForPatrolAppService();
return instrumentation.listDartTests();
}

public MainActivityTest(String dartTestName) {
this.dartTestName = dartTestName;
}

private final String dartTestName;

@Test
public void runDartTest() {
PatrolJUnitRunner instrumentation = (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation();
instrumentation.runDartTest(dartTestName);
}
}
17 changes: 5 additions & 12 deletions docker-compose.yaml → backend-docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,19 @@
version: "3"

services:
tmail-frontend:
image: linagora/tmail-web:master
container_name: tmail-frontend
ports:
- "8080:80"
volumes:
- ./env.file:/usr/share/nginx/html/assets/env.file
networks:
- tmail
depends_on:
- tmail-backend

tmail-backend:
image: linagora/tmail-backend:memory-branch-master
container_name: tmail-backend
volumes:
- ./jwt_publickey:/root/conf/jwt_publickey
- ./jwt_privatekey:/root/conf/jwt_privatekey
- ./mailetcontainer.xml:/root/conf/mailetcontainer.xml
- ./imapserver.xml:/root/conf/imapserver.xml
- ./jmap.properties:/root/conf/jmap.properties
ports:
- "80:80"
environment:
- DOMAIN=example.com
networks:
- tmail

Expand Down
61 changes: 61 additions & 0 deletions backend-docker/imapserver.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->

<!-- Read https://james.apache.org/server/config-imap4.html for further details -->
<imapservers>
<imapserver enabled="true">
<jmxName>imapserver</jmxName>
<bind>0.0.0.0:143</bind>
<connectionBacklog>200</connectionBacklog>
<tls socketTLS="false" startTLS="true">
<!-- To create a new keystore execute:
keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-->
<keystore>file://conf/keystore</keystore>
<secret>james72laBalle</secret>
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
</tls>
<connectionLimit>0</connectionLimit>
<connectionLimitPerIP>0</connectionLimitPerIP>
<idleTimeInterval>120</idleTimeInterval>
<idleTimeIntervalUnit>SECONDS</idleTimeIntervalUnit>
<enableIdle>true</enableIdle>
<plainAuthDisallowed>false</plainAuthDisallowed>
</imapserver>
<imapserver enabled="true">
<jmxName>imapserver-ssl</jmxName>
<bind>0.0.0.0:993</bind>
<connectionBacklog>200</connectionBacklog>
<tls socketTLS="true" startTLS="false">
<!-- To create a new keystore execute:
keytool -genkey -alias james -keyalg RSA -keystore /path/to/james/conf/keystore
-->
<keystore>file://conf/keystore</keystore>
<secret>james72laBalle</secret>
<provider>org.bouncycastle.jce.provider.BouncyCastleProvider</provider>
</tls>
<connectionLimit>0</connectionLimit>
<connectionLimitPerIP>0</connectionLimitPerIP>
<idleTimeInterval>120</idleTimeInterval>
<idleTimeIntervalUnit>SECONDS</idleTimeIntervalUnit>
<enableIdle>true</enableIdle>
</imapserver>
</imapservers>
1 change: 1 addition & 0 deletions backend-docker/jmap.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
url.prefix=https://50e9-2402-9d80-85a-fe80-805b-e215-ab33-3def.ngrok-free.app
Copy link
Member Author

Choose a reason for hiding this comment

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

what is this domain? is it static?

Copy link
Contributor

Choose a reason for hiding this comment

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

It will change everytime the test workflow is run, so no, it is not static.

155 changes: 155 additions & 0 deletions backend-docker/mailetcontainer.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<?xml version="1.0"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->

<!-- Read https://james.apache.org/server/config-mailetcontainer.html for further details -->
<mailetcontainer enableJmx="true">

<context>
<!-- When the domain part of the postmaster mailAddress is missing, the default domain is appended.
You can configure it to (for example) <postmaster>[email protected]</postmaster> -->
<postmaster>postmaster</postmaster>
</context>

<spooler>
<threads>20</threads>
<errorRepository>memory://var/mail/error/</errorRepository>
</spooler>

<processors>
<processor state="root" enableJmx="true">
<mailet match="All" class="PostmasterAlias"/>
<mailet match="RelayLimit=30" class="Null"/>
<mailet match="All" class="ToProcessor">
<processor>transport</processor>
</mailet>
</processor>

<processor state="error" enableJmx="true">
<mailet match="All" class="MetricsMailet">
<metricName>mailetContainerErrors</metricName>
</mailet>
<mailet match="All" class="Bounce"/>
<mailet match="All" class="ToRepository">
<repositoryPath>memory://var/mail/error/</repositoryPath>
<onMailetException>propagate</onMailetException>
</mailet>
</processor>

<processor state="transport" enableJmx="true">
<matcher name="relay-allowed" match="org.apache.james.mailetcontainer.impl.matchers.Or">
<matcher match="SMTPAuthSuccessful"/>
<matcher match="SMTPIsAuthNetwork"/>
<matcher match="SentByMailet"/>
<matcher match="org.apache.james.jmap.mailet.SentByJmap"/>
</matcher>

<mailet match="All" class="RemoveMimeHeader">
<name>bcc</name>
<onMailetException>ignore</onMailetException>
</mailet>
<mailet match="All" class="RecipientRewriteTable">
<errorProcessor>rrt-error</errorProcessor>
</mailet>
<mailet match="RecipientIsLocal" class="ToProcessor">
<processor>local-delivery</processor>
</mailet>
<mailet match="HostIsLocal" class="ToProcessor">
<processor>local-address-error</processor>
<notice>550 - Requested action not taken: no such user here</notice>
</mailet>
<mailet match="relay-allowed" class="ToProcessor">
<processor>relay</processor>
</mailet>
<mailet match="All" class="ToProcessor">
<processor>relay-denied</processor>
</mailet>
</processor>

<processor state="local-delivery" enableJmx="true">
<mailet match="All" class="VacationMailet"/>
<mailet match="All" class="Sieve"/>
<mailet match="All" class="AddDeliveredToHeader"/>
<mailet match="All" class="org.apache.james.jmap.mailet.filter.JMAPFiltering"/>
<mailet match="SenderIsLocal" class="com.linagora.tmail.mailets.ContactsCollection">
<attribute>ContactAttribute1</attribute>
</mailet>
<mailet match="All" class="com.linagora.tmail.mailets.TmailLocalDelivery"/>
</processor>

<processor state="relay" enableJmx="true">
<mailet match="All" class="RemoteDelivery">
<outgoingQueue>outgoing</outgoingQueue>
<delayTime>5000, 100000, 500000</delayTime>
<maxRetries>3</maxRetries>
<maxDnsProblemRetries>0</maxDnsProblemRetries>
<deliveryThreads>10</deliveryThreads>
<sendpartial>true</sendpartial>
<bounceProcessor>bounces</bounceProcessor>
</mailet>
</processor>

<processor state="local-address-error" enableJmx="true">
<mailet match="All" class="MetricsMailet">
<metricName>mailetContainerLocalAddressError</metricName>
</mailet>
<mailet match="All" class="Bounce">
<attachment>none</attachment>
</mailet>
<mailet match="All" class="ToRepository">
<repositoryPath>memory://var/mail/address-error/</repositoryPath>
</mailet>
</processor>

<processor state="relay-denied" enableJmx="true">
<mailet match="All" class="MetricsMailet">
<metricName>mailetContainerRelayDenied</metricName>
</mailet>
<mailet match="All" class="Bounce">
<attachment>none</attachment>
</mailet>
<mailet match="All" class="ToRepository">
<repositoryPath>memory://var/mail/relay-denied/</repositoryPath>
<notice>Warning: You are sending an e-mail to a remote server. You must be authenticated to perform such an operation</notice>
</mailet>
</processor>

<processor state="bounces" enableJmx="true">
<mailet match="All" class="MetricsMailet">
<metricName>bounces</metricName>
</mailet>
<mailet match="All" class="DSNBounce">
<passThrough>false</passThrough>
</mailet>
</processor>

<processor state="rrt-error" enableJmx="false">
<mailet match="All" class="ToRepository">
<repositoryPath>memory://var/mail/rrt-error/</repositoryPath>
<passThrough>true</passThrough>
</mailet>
<mailet match="IsSenderInRRTLoop" class="Null"/>
<mailet match="All" class="Bounce"/>
</processor>

</processors>

</mailetcontainer>

Loading
Loading