Skip to content

Commit 8d1f98f

Browse files
committed
Add migrated tests and infra to run on uberjenkins
1 parent 82805c1 commit 8d1f98f

14 files changed

Lines changed: 741 additions & 2 deletions
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
pipeline {
2+
agent none
3+
parameters {
4+
choice(name: 'CBL_EDITION', choices: ['enterprise', 'community'], description: 'Couchbase Lite Edition')
5+
string(name: 'CBL_VERSION', defaultValue: '4.0.0', description: 'Couchbase Lite Version')
6+
string(name: 'CBL_BUILD', defaultValue: '', description: 'Couchbase Lite Build Number')
7+
string(name: 'CBL_DATASET_VERSION', defaultValue: '4.0', description: "The dataset version to use (e.g. 3.2 or 4.0)")
8+
string(name: 'SGW_VERSION', defaultValue: '', description: "The version of Sync Gateway to download")
9+
}
10+
stages {
11+
stage('Init') {
12+
steps {
13+
script {
14+
if (params.CBL_VERSION == '') { error "CBL_VERSION is required" }
15+
if (params.CBL_BUILD == '') { error "CBL_BUILD is required" }
16+
if (params.SGW_VERSION == '') { error "SGW_VERSION is required" }
17+
currentBuild.displayName = "${params.CBL_VERSION}-${params.CBL_BUILD}-${CBL_EDITION} (#${currentBuild.number})"
18+
currentBuild.description = "Dataset: ${params.CBL_DATASET_VERSION}"
19+
}
20+
}
21+
}
22+
stage('Run Test') {
23+
agent { label 'mac-mini-new' }
24+
environment {
25+
KEYCHAIN_PASSWORD = credentials('mobile-qe-keychain')
26+
}
27+
steps {
28+
// Unlock keychain:
29+
sh 'security unlock-keychain -p ${KEYCHAIN_PASSWORD} ~/Library/Keychains/login.keychain-db'
30+
echo "Run iOS Test"
31+
timeout(time: 60, unit: 'MINUTES') {
32+
sh """
33+
export PATH="/opt/homebrew/opt/python@3.10/bin:/opt/homebrew/bin:/usr/local/bin:\$PATH"
34+
export AWS_PROFILE=mobile-for-now
35+
jenkins/pipelines/QE/ios/test.sh ${params.CBL_EDITION} ${params.CBL_VERSION} ${params.CBL_BUILD} ${params.CBL_DATASET_VERSION} ${params.SGW_VERSION} ~/.ssh/jborden.pem
36+
"""
37+
38+
}
39+
}
40+
post {
41+
always {
42+
echo "Teardown iOS Test"
43+
timeout(time: 5, unit: 'MINUTES') {
44+
sh """
45+
export PATH="/opt/homebrew/opt/python@3.10/bin:/opt/homebrew/bin:/usr/local/bin:\$PATH"
46+
export AWS_PROFILE=mobile-for-now
47+
jenkins/pipelines/QE/ios/teardown.sh
48+
"""
49+
}
50+
}
51+
}
52+
}
53+
}
54+
post {
55+
failure {
56+
mail bcc: '', body: "Project: <a href='${env.BUILD_URL}'>${env.JOB_NAME}</a> has failed!", cc: '', charset: 'UTF-8', from: 'jenkins@couchbase.com', mimeType: 'text/html', replyTo: 'no-reply@couchbase.com', subject: "${env.JOB_NAME} failed", to: "vipul.bhardwaj@couchbase.com";
57+
}
58+
}
59+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://packages.couchbase.com/couchbase-lite/testserver.schema.json",
3+
"test-servers": ["http://{{test-server-ip}}:8080"],
4+
"sync-gateways": [{"hostname": "{{test-client-ip}}", "tls": true}],
5+
"couchbase-servers": [{"hostname": "{{test-client-ip}}"}],
6+
"logslurp": "{{test-client-ip}}:8180",
7+
"greenboard": {"hostname": "jenkins.mobiledev.couchbase.com", "username": "writer", "password": "couchbase2" },
8+
"api-version": 1
9+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
from io import TextIOWrapper
6+
from pathlib import Path
7+
from typing import cast
8+
9+
import click
10+
11+
SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__)))
12+
13+
if __name__ == "__main__":
14+
sys.path.append(str(SCRIPT_DIR.parents[3]))
15+
if isinstance(sys.stdout, TextIOWrapper):
16+
cast(TextIOWrapper, sys.stdout).reconfigure(encoding="utf-8")
17+
18+
from jenkins.pipelines.shared.setup_test import setup_test
19+
20+
21+
@click.command()
22+
@click.argument("cbl_version")
23+
@click.argument("dataset_version")
24+
@click.argument("sgw_version")
25+
@click.option(
26+
"--private_key",
27+
help="The private key to use for the SSH connection (if not default)",
28+
)
29+
def cli_entry(
30+
cbl_version: str,
31+
dataset_version: str,
32+
sgw_version: str,
33+
private_key: str | None,
34+
) -> None:
35+
setup_test(
36+
cbl_version,
37+
dataset_version,
38+
sgw_version,
39+
SCRIPT_DIR / "topology_single_device.json",
40+
SCRIPT_DIR / "config.json",
41+
"swift_ios",
42+
private_key,
43+
setup_dir="QE",
44+
)
45+
46+
47+
if __name__ == "__main__":
48+
cli_entry()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
6+
source $SCRIPT_DIR/../../shared/config.sh
7+
8+
export PYTHONPATH=$SCRIPT_DIR/../../../
9+
pushd $AWS_ENVIRONMENT_DIR
10+
create_venv venv
11+
source venv/bin/activate
12+
pip install -r requirements.txt
13+
python3 ./stop_backend.py --topology topology_setup/topology.json

jenkins/pipelines/QE/ios/test.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
trap 'echo "$BASH_COMMAND (line $LINENO) failed, exiting..."; exit 1' ERR
4+
set -euo pipefail
5+
6+
EDITION=${1}
7+
CBL_VERSION=${2}
8+
CBL_BLD_NUM=${3}
9+
CBL_DATASET_VERSION=${4}
10+
SGW_VERSION=${5}
11+
private_key_path=${6}
12+
13+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
14+
source $SCRIPT_DIR/../../shared/config.sh
15+
16+
echo "Setup backend..."
17+
18+
create_venv venv
19+
source venv/bin/activate
20+
pip install -r $AWS_ENVIRONMENT_DIR/requirements.txt
21+
if [ -n "$private_key_path" ]; then
22+
python3 $SCRIPT_DIR/setup_test.py $CBL_VERSION-$CBL_BLD_NUM $CBL_DATASET_VERSION $SGW_VERSION --private_key $private_key_path
23+
else
24+
python3 $SCRIPT_DIR/setup_test.py $CBL_VERSION-$CBL_BLD_NUM $CBL_DATASET_VERSION $SGW_VERSION
25+
fi
26+
deactivate
27+
28+
# Run Tests :
29+
echo "Run tests..."
30+
31+
pushd "${QE_TESTS_DIR}" > /dev/null
32+
create_venv venv
33+
. venv/bin/activate
34+
pip install -r requirements.txt
35+
pytest -v --no-header -W ignore::DeprecationWarning --config config.json test_no_conflicts.py::TestNoConflicts::test_sg_cbl_updates_concurrently_with_push_pull
36+
deactivate
37+
popd > /dev/null
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "../../../../environment/aws/topology_setup/topology_schema.json",
3+
"test_servers": [
4+
{
5+
"platform": "swift_ios",
6+
"cbl_version": "{{version}}",
7+
"dataset_version": "{{dataset_version}}",
8+
"location": "00008110-000E544201D1401E"
9+
}
10+
],
11+
"include": "../../../../environment/aws/topology_setup/default_topology.json"
12+
}

jenkins/pipelines/shared/config.psm1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ Set-Variable -Name ENVIRONMENT_DIR -Value (Find-Dir -TargetDir "environment") -O
3939

4040
Set-Variable -Name SHARED_PIPELINES_DIR -Value (Join-Path -Path $PIPELINES_DIR -ChildPath "shared") -Option ReadOnly
4141
Set-Variable -Name DEV_E2E_PIPELINES_DIR -Value (Join-Path -Path $PIPELINES_DIR -ChildPath "dev_e2e") -Option ReadOnly
42+
Set-Variable -Name QE_TESTS_DIR -Value (Join-Path -Path $TESTS_DIR -ChildPath "QE") -Option ReadOnly
43+
Set-Variable -Name QE_PIPELINES_DIR -Value (Join-Path -Path $PIPELINES_DIR -ChildPath "QE") -Option ReadOnly
4244
Set-Variable -Name DEV_E2E_TESTS_DIR -Value (Join-Path -Path $TESTS_DIR -ChildPath "dev_e2e") -Option ReadOnly
4345
Set-Variable -Name AWS_ENVIRONMENT_DIR -Value (Join-Path -Path $ENVIRONMENT_DIR -ChildPath "aws") -Option ReadOnly
4446

@@ -49,11 +51,13 @@ ENVIRONMENT_DIR: $ENVIRONMENT_DIR
4951
SHARED_PIPELINES_DIR: $SHARED_PIPELINES_DIR
5052
DEV_E2E_PIPELINES_DIR: $DEV_E2E_PIPELINES_DIR
5153
DEV_E2E_TESTS_DIR: $DEV_E2E_TESTS_DIR
54+
QE_TESTS_DIR: $QE_TESTS_DIR
55+
QE_PIPELINES_DIR: $QE_PIPELINES_DIR
5256
AWS_ENVIRONMENT_DIR: $AWS_ENVIRONMENT_DIR
5357
"@
5458

5559
Write-Box -Content $content -Title "Defining the following values:"
5660

5761
Export-ModuleMember -Variable PIPELINES_DIR, TESTS_DIR, `
5862
ENVIRONMENT_DIR, SHARED_PIPELINES_DIR, DEV_E2E_PIPELINES_DIR, `
59-
DEV_E2E_TESTS_DIR, AWS_ENVIRONMENT_DIR
63+
DEV_E2E_TESTS_DIR, QE_PIPELINES_DIR, QE_TESTS_DIR, AWS_ENVIRONMENT_DIR

jenkins/pipelines/shared/config.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ readonly TEST_SERVER_DIR=$(find_dir servers) || exit 1
6464
readonly SHARED_PIPELINES_DIR="$PIPELINES_DIR/shared"
6565
readonly DEV_E2E_PIPELINES_DIR="$PIPELINES_DIR/dev_e2e"
6666
readonly DEV_E2E_TESTS_DIR="$TESTS_DIR/dev_e2e"
67+
readonly QE_TESTS_DIR="$TESTS_DIR/QE"
68+
readonly QE_PIPELINES_DIR="$PIPELINES_DIR/QE"
6769
readonly AWS_ENVIRONMENT_DIR="$ENVIRONMENT_DIR/aws"
6870

6971
export PIPELINES_DIR TESTS_DIR ENVIRONMENT_DIR TEST_SERVER_DIR
@@ -76,6 +78,8 @@ TEST_SERVER_DIR: $TEST_SERVER_DIR
7678
SHARED_PIPELINES_DIR: $SHARED_PIPELINES_DIR
7779
DEV_E2E_PIPELINES_DIR: $DEV_E2E_PIPELINES_DIR
7880
DEV_E2E_TESTS_DIR: $DEV_E2E_TESTS_DIR
81+
QE_TESTS_DIR: $QE_TESTS_DIR
82+
QE_PIPELINES_DIR: $QE_PIPELINES_DIR
7983
AWS_ENVIRONMENT_DIR: $AWS_ENVIRONMENT_DIR"
8084

8185
print_box "$content" "Defining the following values:"

jenkins/pipelines/shared/setup_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,12 @@ def setup_test(
4949
private_key: str | None = None,
5050
couchbase_version: str = "7.6",
5151
public_key_name: str = "jborden",
52+
setup_dir: str = "dev_e2e",
5253
) -> None:
5354
"""
5455
Sets up a testing environment with the specified CBL version, dataset version, and Sync Gateway version.
5556
"""
56-
config_file_out = SCRIPT_DIR.parents[2] / "tests" / "dev_e2e" / "config.json"
57+
config_file_out = SCRIPT_DIR.parents[2] / "tests" / setup_dir / "config.json"
5758
topology_file_out = (
5859
SCRIPT_DIR.parents[2]
5960
/ "environment"

tests/QE/config.example.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://packages.couchbase.com/couchbase-lite/testserver.schema.json",
3+
"test-servers": ["http://localhost:8080"],
4+
"sync-gateways": [{"hostname": "localhost"}],
5+
"couchbase-servers": [{"hostname": "localhost"}],
6+
"api-version": 1
7+
}

0 commit comments

Comments
 (0)