From 00eba1c788820607ecaaa150491a87e8ccf643f1 Mon Sep 17 00:00:00 2001 From: Jonathan Reams Date: Thu, 12 Sep 2024 09:00:58 -0400 Subject: [PATCH] RCORE-2257 Remove unneeded evergreen tasks/build variants (#8025) --- evergreen/bloaty_to_json.py | 175 ------- evergreen/config.yml | 574 +---------------------- evergreen/configure_baas_proxy.sh | 237 ---------- evergreen/proxy-network-faults.toxics | 4 - evergreen/proxy-nonideal-transfer.toxics | 5 - evergreen/setup_baas_host.sh | 279 ----------- evergreen/setup_baas_host_local.sh | 269 ----------- evergreen/setup_baas_proxy.sh | 263 ----------- evergreen/wait_for_baas.sh | 100 ---- evergreen/wait_for_remote_baas.sh | 126 ----- 10 files changed, 5 insertions(+), 2027 deletions(-) delete mode 100755 evergreen/bloaty_to_json.py delete mode 100755 evergreen/configure_baas_proxy.sh delete mode 100644 evergreen/proxy-network-faults.toxics delete mode 100644 evergreen/proxy-nonideal-transfer.toxics delete mode 100755 evergreen/setup_baas_host.sh delete mode 100755 evergreen/setup_baas_host_local.sh delete mode 100755 evergreen/setup_baas_proxy.sh delete mode 100755 evergreen/wait_for_baas.sh delete mode 100755 evergreen/wait_for_remote_baas.sh diff --git a/evergreen/bloaty_to_json.py b/evergreen/bloaty_to_json.py deleted file mode 100755 index 47b5967d083..00000000000 --- a/evergreen/bloaty_to_json.py +++ /dev/null @@ -1,175 +0,0 @@ -#!/usr/bin/env python3 -from __future__ import annotations - -import argparse -import json -import re -from csv import DictReader -from pathlib import Path - -parser = argparse.ArgumentParser(description='Checks how bloated realm has become') -parser.add_argument( - '--short-symbols-input', - type=Path, - help='Path to CSV output of short symbols input file', -) -parser.add_argument( - '--sections-input', - type=Path, - help='Path to CSV output of sections input file', -) - -parser.add_argument( - '--compileunits-input', - type=Path, - help='Path to CSV output of compileunits input file', -) - -parser.add_argument( - '--analyzed-file', - type=str, - help='Name of file being analyzed by bloaty', -) - -evgOpts = parser.add_argument_group('Evergreen Metadata') -evgOpts.add_argument('--output', type=Path, help='The evergreen json output filename') -evgOpts.add_argument('--project', type=str, help='Evergreen project this script is running in') -evgOpts.add_argument('--execution', type=int, help='Execution # of this evergreen task') -evgOpts.add_argument( - '--is-patch', - type=bool, - dest='is_patch', - help='Specify if this is not a patch build', -) -evgOpts.add_argument( - '--build-variant', - type=str, - dest='build_variant', - help='Build variant of the evergreen task', -) -evgOpts.add_argument('--branch', type=str, help='Git branch that was being tested') -evgOpts.add_argument('--revision', type=str, help='Git sha being tested') -evgOpts.add_argument('--task-id', type=str, dest='task_id', help='Evergreen task ID of this task') -evgOpts.add_argument('--task-name', type=str, dest='task_name', help='Name of this evergreen task') -evgOpts.add_argument( - '--revision-order-id', - type=str, - dest='revision_order_id', - help='Evergreen revision order id', -) -evgOpts.add_argument('--version-id', type=str, dest='version_id', help='Name of this evergreen version') - -args = parser.parse_args() -patch_username : str = '' - -def parse_patch_order(): - global patch_username - patch_order_re = re.compile(r"(?P[\w\@\.]+)_(?P\d+)") - match_obj = patch_order_re.match(args.revision_order_id) - patch_username = match_obj.group('patch_username') - return int(match_obj.group('patch_order')) -evg_order = int(args.revision_order_id) if not args.is_patch else parse_patch_order() - -cxx_method_re = re.compile( - # namespaces/parent class name - r"(?P(?:(?:[_a-zA-Z][\w]*)(?:<.*>)?(?:::)|(?:\(anonymous namespace\)::))+)" + - r"(?P[\~a-zA-Z_][\w]*)(?:<.*>)?" + # function/class name - r"(?P\(\))?" + # if this is function, this will capture "()" - # will be a number if this is a lambda - r"(?:::\{lambda\(\)\#(?P\d+)\}::)?") - -elf_section_re = re.compile(r"\[section \.(?P[\w\.\-]+)\]") - -items : list[dict] = [] -sections_seen = set() -if args.short_symbols_input: - with open(args.short_symbols_input, 'r') as csv_file: - input_csv_reader = DictReader(csv_file) - for row in input_csv_reader: - raw_name = row['shortsymbols'] - if match := cxx_method_re.search(raw_name): - ns = match.group('ns').rstrip(':') - - node_name = match.group('name') - if match.group('lambda_number'): - node_name = "{} lambda #{}".format(node_name, match.group('lambda_number')) - - type_str: str = 'symbol' - if match.group('lambda_number'): - type_str = 'lambda' - elif match.group('is_function'): - type_str = 'function' - - items.append({ - 'type': type_str, - 'name': raw_name, - 'ns': ns, - 'file_size': int(row['filesize']), - 'vm_size': int(row['vmsize']), - }) - - elif match := elf_section_re.search(raw_name): - section_name = match.group('section_name') - type_str: str = 'section' if not section_name.startswith('.debug') else 'debug_section' - if section_name not in sections_seen: - items.append({ - 'type': type_str, - 'name': section_name, - 'file_size': int(row['filesize']), - 'vm_size': int(row['vmsize']) - }) - else: - items.append({ - 'type': 'symbol', - 'name': raw_name, - 'file_size': int(row['filesize']), - 'vm_size': int(row['vmsize']), - }) - -if args.sections_input: - with open(args.sections_input, 'r') as csv_file: - input_csv_reader = DictReader(csv_file) - - for row in input_csv_reader: - section_name = row['sections'] - type_str: str = 'section' if not section_name.startswith('.debug') else 'debug_section' - if section_name not in sections_seen: - items.append({ - 'name': section_name, - 'type': type_str, - 'file_size': int(row['filesize']), - 'vm_size': int(row['vmsize']) - }) - -if args.sections_input: - with open(args.compileunits_input, 'r') as csv_file: - input_csv_reader = DictReader(csv_file) - - for row in input_csv_reader: - compileunit_name = row['compileunits'] - if not elf_section_re.search(compileunit_name): - items.append({ - 'name': compileunit_name, - 'type': 'compileunit', - 'file_size': int(row['filesize']), - 'vm_size': int(row['vmsize']) - }) - -output_obj = { - 'items': items, - 'execution': args.execution, - 'is_mainline': (args.is_patch is not True), - 'analyzed_file': args.analyzed_file, - 'order': evg_order, - 'project': args.project, - 'branch': args.branch, - 'build_variant': args.build_variant, - 'revision': args.revision, - 'task_id': args.task_id, - 'task_name': args.task_name, - 'version_id': args.version_id, - 'patch_username': patch_username -} - -with open(args.output, 'w') as out_fp: - json.dump(output_obj, out_fp) diff --git a/evergreen/config.yml b/evergreen/config.yml index e14afde6c9b..09d1c4e1146 100644 --- a/evergreen/config.yml +++ b/evergreen/config.yml @@ -239,33 +239,6 @@ functions: make "-j$NPROC" 2>&1 popd > /dev/null # realm-core - "run benchmark": - - command: shell.exec - params: - working_dir: realm-core - shell: bash - script: |- - set -o errexit - - if [[ -z "${benchmark_name}" ]]; then - echo "No benchmark specified." - exit 1 - fi - - export UNITTEST_THREADS=1 - - BENCHMARK=$(./evergreen/abspath.sh ./build/test/benchmark-${benchmark_name}/${cmake_build_type|Debug}/realm-benchmark-${benchmark_name}) - echo "Going to run benchmark $BENCHMARK" - - [[ -d benchmark_results ]] && rm -rf benchmark_results - mkdir benchmark_results - cd benchmark_results - - $BENCHMARK "$(pwd)/" - - command: perf.send - params: - file: './realm-core/benchmark_results/results.latest.json' - "run tests": - command: expansions.update params: @@ -389,92 +362,6 @@ functions: file_location: realm-core/${task_name}_results.json "upload baas artifacts": - - command: shell.exec - params: - working_dir: realm-core - shell: bash - script: |- - set -o errexit - set -o pipefail - set -o verbose - - if [[ -n "${disable_tests_against_baas|}" ]]; then - exit 0 - fi - - # Copy the baas_server log from the remote baas host if it exists - if [[ ! -f baas_host.yml || ! -f .baas_ssh_key ]]; then - echo "Skipping - no remote baas host or remote baas host definitions not found" - exit 0 - fi - - BAAS_HOST_NAME=$(tr -d '"[]{}' < baas_host.yml | cut -d , -f 1 | awk -F : '{print $2}') - export BAAS_HOST_NAME - - ssh_user="$(printf "ubuntu@%s" "$BAAS_HOST_NAME")" - ssh_options="-o ForwardAgent=yes -o IdentitiesOnly=yes -o StrictHostKeyChecking=no -o ConnectTimeout=60 -i .baas_ssh_key" - - # Copy the baas_server.log, mongod.log and (optionally) baas_proxy.log files from the remote baas host - REMOTE_PATH=/data/baas-remote - REMOTE_BAAS_PATH="$REMOTE_PATH/baas-work-dir" - REMOTE_BAAS_DB_PATH="$REMOTE_BAAS_PATH/mongodb-dbpath" - REMOTE_PROXY_PATH="$REMOTE_PATH/baas-proxy-dir" - - LOCAL_BAAS_PATH=./baas-work-dir - LOCAL_BAAS_DB_PATH="$LOCAL_BAAS_PATH/mongodb-dbpath" - LOCAL_PROXY_PATH=./baas-proxy-dir - - mkdir -p "$LOCAL_BAAS_PATH/" - mkdir -p "$LOCAL_BAAS_DB_PATH/" - mkdir -p "$LOCAL_PROXY_PATH/" - scp $ssh_options $ssh_user:"$REMOTE_BAAS_PATH/baas_server.log" "$LOCAL_BAAS_PATH/baas_server.log" || true - scp $ssh_options $ssh_user:"$REMOTE_BAAS_DB_PATH/mongod.log" "$LOCAL_BAAS_DB_PATH/mongod.log" || true - scp $ssh_options $ssh_user:"$REMOTE_PROXY_PATH/baas_proxy.log" "$LOCAL_PROXY_PATH/baas_proxy.log" || true - - - command: s3.put - params: - aws_key: '${artifacts_aws_access_key}' - aws_secret: '${artifacts_aws_secret_key}' - local_file: 'realm-core/baas-work-dir/baas_server.log' - remote_file: 'realm-core-stable/${branch_name}/${task_id}/${execution}/baas_server.log' - bucket: mciuploads - permissions: public-read - content_type: text/plain - display_name: baas server logs - optional: true - - command: s3.put - params: - aws_key: '${artifacts_aws_access_key}' - aws_secret: '${artifacts_aws_secret_key}' - local_file: 'realm-core/install_baas_output.log' - remote_file: 'realm-core-stable/${branch_name}/${task_id}/${execution}/install_baas_output.log' - bucket: mciuploads - permissions: public-read - content_type: text/plain - display_name: install baas output - optional: true - - command: s3.put - params: - aws_key: '${artifacts_aws_access_key}' - aws_secret: '${artifacts_aws_secret_key}' - local_file: 'realm-core/baas-work-dir/mongodb-dbpath/mongod.log' - remote_file: 'realm-core-stable/${branch_name}/${task_id}/${execution}/mongod.log' - bucket: mciuploads - permissions: public-read - content_type: text/plain - display_name: mongod logs - optional: true - - command: s3.put - params: - aws_key: '${artifacts_aws_access_key}' - aws_secret: '${artifacts_aws_secret_key}' - local_file: 'realm-core/baas-proxy-dir/baas_proxy.log' - remote_file: 'realm-core-stable/${branch_name}/${task_id}/${execution}/baas_proxy.log' - bucket: mciuploads - permissions: public-read - content_type: text/plain - display_name: baas proxy logs - optional: true - command: s3.put params: aws_key: '${artifacts_aws_access_key}' @@ -487,53 +374,6 @@ functions: display_name: trace level test logs optional: true - "upload fuzzer results": - - command: shell.exec - params: - working_dir: realm-core/build/test/realm-fuzzer - script: |- - if ls crash-*> /dev/null 2>&1; then - echo "Found crash file" - #Rename the crash file and the realm file. - #If there is a crash, this will signal that something needs to be uploaded. - mv crash-* realm-fuzzer-crash.txt - mv fuzz-realm.realm fuzzer_realm.realm - fi - - - command: s3.put - params: - working_dir: realm-core/build/test/realm-fuzzer - aws_key: '${artifacts_aws_access_key}' - aws_secret: '${artifacts_aws_secret_key}' - local_file: 'realm-core/build/test/realm-fuzzer/realm-fuzzer-crash.txt' - remote_file: '${project}/${branch_name}/${task_id}/${execution}/realm-fuzzer-crash.txt' - bucket: mciuploads - permissions: public-read - content_type: text/plain - display_name: Crash input file - optional: true - - - command: s3.put - params: - working_dir: realm-core/build/test/realm-fuzzer - aws_key: '${artifacts_aws_access_key}' - aws_secret: '${artifacts_aws_secret_key}' - local_file: 'realm-core/build/test/realm-fuzzer/fuzzer_realm.realm' - remote_file: '${project}/${branch_name}/${task_id}/${execution}/fuzzer_realm.realm' - bucket: mciuploads - permissions: public-read - content_type: application/x-binary - display_name: Realm File - optional: true - - - command: shell.exec - params: - working_dir: realm-core/build/test/realm-fuzzer - script: |- - #remove the crash file and the realm produced by the fuzzer run - rm realm-fuzzer-crash.txt - rm fuzzer_realm.realm - "run hang analyzer": - command: shell.exec params: @@ -628,149 +468,6 @@ functions: python $HANG_ANALYZER_PATH - "launch remote baas": - - command: host.create - params: - provider: ec2 - distro: ubuntu2004-medium - - command: host.list - params: - num_hosts: 1 - path: realm-core/baas_host.yml - timeout_seconds: 600 - wait: true - - command: shell.exec - params: - working_dir: realm-core - shell: bash - # Do NOT use verbose for this script since it would reveal the values of secrets - script: |- - set -o errexit - set -o pipefail - - if [[ -n "${disable_tests_against_baas|}" ]]; then - echo "Should not be using remote baas if the tests are not being used" - exit 0 - fi - - # Save the remote host ssh key and details to files - echo "${__project_aws_ssh_key_value}" > .baas_ssh_key - chmod 600 .baas_ssh_key - - BAAS_HOST_NAME=$(tr -d '"[]{}' < baas_host.yml | cut -d , -f 1 | awk -F : '{print $2}') - - # Github SSH host key updated 06/26/2023 - # Use 'github_known_hosts' expansion for GITHUB_KNOWN_HOSTS below once EVG-20410 has been implemented - cat >baas_host_vars.sh <&1 | tee install_baas_output.log - - "wait for baas to start": - - command: shell.exec - params: - working_dir: realm-core - shell: bash - script: |- - set -o errexit - set -o verbose - - if [[ -n "${disable_tests_against_baas|}" ]]; then - exit 0 - fi - - # Don't print out the tail of the log file - ./evergreen/wait_for_baas.sh -s -w ./baas-work-dir -l "" - - echo "Baas is started!" - - "wait for remote baas to start": - - command: shell.exec - params: - working_dir: realm-core - shell: bash - script: |- - set -o errexit - set -o verbose - - if [[ -n "${disable_tests_against_baas|}" ]]; then - exit 0 - fi - - # Don't print out the tail of the log file - ./evergreen/wait_for_remote_baas.sh -i ./.baas_ssh_key ./baas_host_vars.sh ./.baas_ssh_key - - echo "Baas is started!" - - "setup proxy parameters": - - command: shell.exec - params: - working_dir: realm-core - shell: bash - script: |- - set -o errexit - set -o pipefail - set -o verbose - - if [[ -n "${disable_tests_against_baas|}" ]]; then - echo "Error: Baas is disabled for network tests" - exit 1 - fi - - if [[ -z "${proxy_toxics_file|}" ]]; then - echo "Error: Baas proxy toxics config file was not provided" - exit 1 - fi - - if [[ -n "${proxy_toxics_randoms|}" ]]; then - PROXY_RANDOMS="-r ${proxy_toxics_randoms}" - fi - - # Configure the toxics for the baas proxy - evergreen/configure_baas_proxy.sh $PROXY_RANDOMS "${proxy_toxics_file}" - # Display the list of configured toxics - curl --silent http://localhost:8474/proxies/baas_proxy/toxics - "check branch state": - command: shell.exec type: setup @@ -953,30 +650,6 @@ tasks: test_filter: CoreTests test_executable_name: "realm-tests" -- name: benchmark-common-tasks - exec_timeout_secs: 1800 - tags: [ "benchmark" ] - commands: - - func: "run benchmark" - vars: - benchmark_name: common-tasks - -- name: benchmark-crud - exec_timeout_secs: 1800 - tags: [ "benchmark" ] - commands: - - func: "run benchmark" - vars: - benchmark_name: crud - -- name: benchmark-sync - exec_timeout_secs: 1800 - tags: [ "benchmark" ] - commands: - - func: "run benchmark" - vars: - benchmark_name: sync - - name: sync-tests tags: [ "test_suite", "for_pull_requests" ] exec_timeout_secs: 1800 @@ -1020,31 +693,6 @@ tasks: verbose_test_output: true - func: "check branch state" -- name: baas-network-tests - # Uncomment once tests are passing - tags: [ "disabled" ] - # tags: [ "for_nightly_tests" ] - # These tests can be manually requested for patches and pull requests - allowed_requesters: [ "ad_hoc", "patch", "github_pr" ] - # The network tests can take a really long time, so we give the test up to 4 - # hours to complete - exec_timeout_secs: 14400 - commands: - - func: "launch remote baas" - vars: - baas_proxy: On - - func: "compile" - vars: - target_to_build: ObjectStoreTests - - func: "wait for baas to start" - - func: "setup proxy parameters" - - func: "run tests" - vars: - test_label: objstore-baas - test_executable_name: "realm-object-store-tests" - verbose_test_output: true - - func: "check branch state" - - name: process_coverage_data tags: [ "for_pull_requests" ] exec_timeout_secs: 1800 @@ -1190,16 +838,6 @@ tasks: echo "COMMAND: git clang-format -f --commit $format_ref" exit 1 -- name: fuzzer - tags: [ "for_nightly_tests" ] - allowed_requesters: [ "ad_hoc", "patch" ] - commands: - - command: shell.exec - params: - working_dir: realm-core/build/test/realm-fuzzer - shell: /bin/bash - script: |- - ${cmake_build_type|Debug}/realm-libfuzz -rss_limit_mb=0 -max_total_time=3600 - name: combined-tests-ios-simulator tags: [ "for_pull_requests" ] @@ -1237,56 +875,6 @@ tasks: 'io.realm.CombinedTests' \ $TEST_RESULTS_FILE -- name: generate-sync-corpus - tags: [ "for_nightly_tests" ] - exec_timeout_secs: 1800 - commands: - - func: "fetch source" - - func: "fetch binaries" - - func: "compile" - vars: - target_to_build: "SyncTests" - - command: shell.exec - params: - working_dir: realm-core - shell: bash - script: |- - set -o errexit - set -o verbose - - if [[ -n "${c_compiler}" && "$(basename ${c_compiler})" = "clang" && -f "$(dirname ${c_compiler})/llvm-symbolizer" ]]; then - LLVM_SYMBOLIZER="$(dirname ${c_compiler})/llvm-symbolizer" - export ASAN_SYMBOLIZER_PATH="$(./evergreen/abspath.sh $LLVM_SYMBOLIZER)" - export TSAN_OPTIONS="external_symbolizer_path=$(./evergreen/abspath.sh $LLVM_SYMBOLIZER)" - fi - - export UNITTEST_EVERGREEN_TEST_RESULTS="$(./evergreen/abspath.sh ${task_name}_results.json)" - if [[ -n "$UNITTEST_EVERGREEN_TEST_RESULTS" && -f "$UNITTEST_EVERGREEN_TEST_RESULTS" ]]; then - rm "$UNITTEST_EVERGREEN_TEST_RESULTS" - fi - export UNITTEST_PROGRESS=1 - export UNITTEST_FILTER="Array_Example Transform_* EmbeddedObjects_*" - export UNITTEST_DUMP_TRANSFORM="changeset_dump" - - export TSAN_OPTIONS="suppressions=$(pwd)/test/tsan.suppress history_size=4 $TSAN_OPTIONS" - export UBSAN_OPTIONS="print_stacktrace=1" - - ./build/test/${cmake_build_type}/realm-sync-tests - - CHANGESET_DUMP_DIR="$(find . -type d -name changeset_dump -print -quit)" - mv "$CHANGESET_DUMP_DIR" changeset_dump - tar -czvf changeset_dump.tgz changeset_dump - - command: s3.put - params: - aws_key: '${artifacts_aws_access_key}' - aws_secret: '${artifacts_aws_secret_key}' - local_file: 'realm-core/changeset_dump.tgz' - remote_file: 'realm-core-stable/${branch_name}/${task_id}/${execution}/changeset_dump.tgz' - bucket: mciuploads - permissions: public-read - content_type: application/gzip - display_name: changeset dump tarball - task_groups: - name: core_tests_group setup_group_can_fail_task: true @@ -1371,21 +959,6 @@ task_groups: tasks: - compile-emscripten -# Runs object-store-tests against baas running on remote host and runs -# the network simulation tests as a separate task for nightly builds -- name: network_tests - max_hosts: 1 - setup_group_can_fail_task: true - setup_group: - - func: "fetch source" - - func: "fetch binaries" - teardown_task: - - func: "upload test results" - - func: "upload baas artifacts" - timeout: - - func: "run hang analyzer" - tasks: - - baas-network-tests # Runs object-store-tests against baas running on remote host - name: compile_test_coverage @@ -1404,18 +977,6 @@ task_groups: - .test_suite - process_coverage_data -- name: benchmarks - setup_group_can_fail_task: true - setup_group: - - func: "fetch source" - - func: "fetch binaries" - - func: "compile" - vars: - target_to_build: "benchmarks" - timeout: - - func: "run hang analyzer" - tasks: - - .benchmark - name: long-running-tests setup_group_can_fail_task: true @@ -1433,18 +994,6 @@ task_groups: tasks: - long-running-core-tests -- name: fuzzer-tests - setup_group_can_fail_task: true - setup_group: - - func: "fetch source" - - func: "fetch binaries" - - func: "compile" - vars: - target_to_build: realm-libfuzz - teardown_task: - - func: "upload fuzzer results" - tasks: - - fuzzer - name: ios-simulator-tests max_hosts: 1 @@ -1592,11 +1141,8 @@ buildvariants: tasks: - name: core_tests_group -# TODO RCORE-2085 ubuntu2004-release/ubuntu2004-arm64 build variants are here until we've established -# a new baseline for the updated ubuntu 2204/clang 18 builders and to generate artifacts for the baas -# team. - name: ubuntu2004-release - display_name: "Ubuntu 20.04 x86_64 (Clang 11 release benchmarks/baas artifacts)" + display_name: "Ubuntu 20.04 x86_64 (Clang 11 release baas artifacts)" run_on: ubuntu2004-large expansions: clang_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/clang%2Bllvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz" @@ -1610,36 +1156,6 @@ buildvariants: python3: /opt/mongodbtoolchain/v3/bin/python3 tasks: - name: compile_test_and_package - - name: benchmarks - - name: generate-sync-corpus - -- name: ubuntu2004-arm64 - display_name: "Ubuntu 20.04 ARM64 (GCC 9 release benchmarks)" - run_on: ubuntu2004-arm64-large - expansions: - cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-linux-aarch64.tar.gz" - cmake_bindir: "./cmake_binaries/bin" - python3: "/opt/mongodbtoolchain/v3/bin/python3" - use_system_openssl: On - fetch_missing_dependencies: On - cmake_build_type: RelWithDebInfo - tasks: - - name: benchmarks - -- name: ubuntu-x86_64-benchmarks - display_name: "Ubuntu x86_64 benchmarks" - run_on: ubuntu2204-large - expansions: - fetch_missing_dependencies: On - cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-linux-x86_64.tar.gz" - cmake_bindir: "./cmake_binaries/bin" - clang_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/clang%2Bllvm-18.1.2-x86_64-linux-gnu.tar.xz" - clang_sha256_sum: "feab4b0f5fba325bfe0f4245710fd19fd74f813f44b5e81eda794f4f75bca343" - c_compiler: "./clang_binaries/bin/clang" - cxx_compiler: "./clang_binaries/bin/clang++" - cmake_build_type: RelWithDebInfo - tasks: - - name: benchmarks - name: ubuntu-release display_name: "Ubuntu (Release build)" @@ -1652,7 +1168,6 @@ buildvariants: python3: /opt/mongodbtoolchain/v3/bin/python3 tasks: - name: compile_test_and_package - - name: benchmarks - name: long-running-tests - name: ubuntu-asan @@ -1708,20 +1223,6 @@ buildvariants: tasks: - name: compile_test -- name: ubuntu-fuzzer - display_name: "Ubuntu (Fuzzer)" - run_on: ubuntu2204-arm64-large - expansions: - fetch_missing_dependencies: On - enable_ubsan: On - c_compiler: "/opt/clang+llvm/bin/clang" - cxx_compiler: "/opt/clang+llvm/bin/clang++" - cmake_build_type: RelWithDebInfo - run_with_encryption: 1 - enable_fuzzer: On - tasks: - - name: fuzzer-tests - - name: ubuntu-emscripten display_name: "Ubuntu (Emscripten x86_64)" run_on: ubuntu2204-large @@ -1743,52 +1244,6 @@ buildvariants: tasks: - name: compile_emscripten -# disable these builders since there are constantly failing and not yet ready for nightly builds -# - name: ubuntu2004-network-nonideal -# display_name: "Ubuntu 20.04 x86_64 (Utunbu2004 - nonideal transfer)" -# run_on: ubuntu2004-large -# expansions: -# clang_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/clang%2Bllvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz" -# cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-linux-x86_64.tar.gz" -# cmake_bindir: "./cmake_binaries/bin" -# fetch_missing_dependencies: On -# c_compiler: "./clang_binaries/bin/clang" -# cxx_compiler: "./clang_binaries/bin/clang++" -# cmake_build_type: RelWithDebInfo -# run_with_encryption: On -# baas_admin_port: 9098 -# test_logging_level: debug -# test_timeout_extra: 60 -# proxy_toxics_file: evergreen/proxy-nonideal-transfer.toxics -# # RANDOM1: bandwidth-upstream limited to between 10-50 KB/s from the client to the server -# # RANDOM2: bandwidth-downstream limited to between 10-50 KB/s from the server to the client -# proxy_toxics_randoms: "10:50|10:50" -# tasks: -# - name: network_tests -# -# - name: ubuntu2004-network-faulty -# display_name: "Ubuntu 20.04 x86_64 (Utunbu2004 - network faults)" -# run_on: ubuntu2004-large -# expansions: -# clang_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/clang%2Bllvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz" -# cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-linux-x86_64.tar.gz" -# cmake_bindir: "./cmake_binaries/bin" -# fetch_missing_dependencies: On -# c_compiler: "./clang_binaries/bin/clang" -# cxx_compiler: "./clang_binaries/bin/clang++" -# cmake_build_type: RelWithDebInfo -# run_with_encryption: On -# baas_admin_port: 9098 -# test_logging_level: debug -# proxy_toxics_file: evergreen/proxy-network-faults.toxics -# # RANDOM1: limit-data-upstream to close connection after between 1000-3000 bytes have been sent -# # RANDOM2: limit-data-downstream to close connection after between 1000-3000 bytes have been received -# # RANDOM3: slow-close-upstream to keep connection to server open after 1000-1500 milliseconds after being closed -# # RANDOM4: reset-peer-upstream after 50-200 seconds to force close the connection to the server -# proxy_toxics_randoms: "1000:3000|1000:3000|1000:1500|50:200" -# tasks: -# - name: network_tests - - name: ubuntu-valgrind display_name: "Ubuntu 22.04 x86_64 (Valgrind)" run_on: ubuntu2204-large @@ -1848,35 +1303,19 @@ buildvariants: - name: core_tests_group - name: macos-release - display_name: "MacOS 11.0 x86_64 (Release build)" - run_on: macos-1100 + display_name: "MacOS 13.0 arm64 (Release build)" + run_on: macos-13-arm64 expansions: cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-macos-universal.tar.gz" cmake_bindir: "./cmake_binaries/CMake.app/Contents/bin" cmake_generator: Xcode max_jobs: $(sysctl -n hw.logicalcpu) cmake_build_type: Release - xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer + xcode_developer_dir: /Applications/Xcode.app/Contents/Developer extra_flags: -DREALM_ENABLE_ASSERTIONS=ON tasks: - - name: benchmarks - - name: compile_test - name: test-on-exfat -- name: macos-1100-arm64-release - display_name: "MacOS 11 arm64 (Release benchmarks)" - run_on: macos-1100-arm64 - expansions: - cmake_url: "https://s3.amazonaws.com/static.realm.io/evergreen-assets/cmake-3.26.3-macos-universal.tar.gz" - cmake_bindir: "./cmake_binaries/CMake.app/Contents/bin" - cmake_generator: Xcode - max_jobs: $(sysctl -n hw.logicalcpu) - cmake_build_type: Release - xcode_developer_dir: /Applications/Xcode13.1.app/Contents/Developer - extra_flags: -DREALM_ENABLE_ASSERTIONS=ON - tasks: - - name: benchmarks - - name: macos display_name: "MacOS 14 arm64" run_on: macos-14-arm64 @@ -1907,8 +1346,6 @@ buildvariants: extra_flags: -DCMAKE_SYSTEM_NAME=Darwin -DCMAKE_OSX_ARCHITECTURES=arm64 tasks: - name: compile_test_and_package - # benchmarks are disabled for now because of perf problems on AWS macos instances. - # - name: benchmarks - name: long-running-tests - name: swift-build-and-test @@ -2107,9 +1544,8 @@ buildvariants: expansions: cmake_bindir: "/cygdrive/c/Program Files/CMake/bin/" cmake_generator: "Visual Studio 16 2019" - extra_flags: "-A x64" cmake_build_type: "Debug" - extra_flags: -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 + extra_flags: -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 max_jobs: $(($(grep -c proc /proc/cpuinfo) / 2)) fetch_missing_dependencies: On python3: "/cygdrive/c/python/python37/python.exe" diff --git a/evergreen/configure_baas_proxy.sh b/evergreen/configure_baas_proxy.sh deleted file mode 100755 index fa2cc5c30ab..00000000000 --- a/evergreen/configure_baas_proxy.sh +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/env bash -# The script to send and execute the configuration to set up the baas proxy toxics. -# -# Usage: -# ./evergreen/configure_baas_proxy.sh [-c PORT] [-r NUM] [-p PATH] [-v] [-h] CONFIG_JSON -# - -set -o errexit -set -o errtrace -set -o pipefail - -CONFIG_PORT=8474 -PROXY_NAME="baas_proxy" -RND_STRING= -RND_MIN= -RND_MAX= -RND_DIFF=32767 -CURL=/usr/bin/curl -VERBOSE= -CONFIG_TMP_DIR= - -function usage() -{ - echo "Usage: configure_baas_proxy.sh [-c PORT] [-r MIN:MAX] [-p PATH] [-t NAME] [-v] [-h] CONFIG_JSON" - echo -e "\tCONFIG_JSON\tPath to baas proxy toxics config file (one toxic config JSON object per line)" - echo "Options:" - echo -e "\t-c PORT\t\tLocal configuration port for proxy HTTP API (default ${CONFIG_PORT})" - echo -e "\t-r MIN:MAX\tString containing one or more sets of min:max values to replace %RANDOM#% in toxics" - echo -e "\t-p PATH\t\tPath to the curl executable (default ${CURL})" - echo -e "\t-t NAME\t\tName of the proxy to be configured (default ${PROXY_NAME})" - echo -e "\t-v\t\tEnable verbose script debugging" - echo -e "\t-h\t\tShow this usage summary and exit" - # Default to 0 if exit code not provided - exit "${1:0}" -} - -while getopts "c:r:p:vh" opt; do - case "${opt}" in - c) CONFIG_PORT="${OPTARG}";; - r) RND_STRING="${OPTARG}";; - p) CURL="${OPTARG}";; - v) VERBOSE="yes";; - h) usage 0;; - *) usage 1;; - esac -done - -TOXIPROXY_URL="http://localhost:${CONFIG_PORT}" - -shift $((OPTIND - 1)) - -if [[ $# -lt 1 ]]; then - echo "Error: Baas proxy toxics config file not provided" - usage 1 -fi -PROXY_JSON_FILE="${1}"; shift; - -if [[ -z "${PROXY_JSON_FILE}" ]]; then - echo "Error: Baas proxy toxics config file value was empty" - usage 1 -elif [[ ! -f "${PROXY_JSON_FILE}" ]]; then - echo "Error: Baas proxy toxics config file not found: ${PROXY_JSON_FILE}" - usage 1 -fi - -if [[ -z "${CURL}" ]]; then - echo "Error: curl path is empty" - usage 1 -elif [[ ! -x "${CURL}" ]]; then - echo "Error: curl path is not valid: ${CURL}" - usage 1 -fi - -trap 'catch $? ${LINENO}' ERR -trap 'on_exit' INT TERM EXIT - -# Set up catch function that runs when an error occurs -function catch() -{ - # Usage: catch EXIT_CODE LINE_NUM - echo "${BASH_SOURCE[0]}: $2: Error $1 occurred while configuring baas proxy" -} - -function on_exit() -{ - # Usage: on_exit - if [[ -n "${CONFIG_TMP_DIR}" && -d "${CONFIG_TMP_DIR}" ]]; then - rm -rf "${CONFIG_TMP_DIR}" - fi -} - -function check_port() -{ - # Usage check_port PORT - port_num="${1}" - if [[ -n "${port_num}" && ${port_num} -gt 0 && ${port_num} -lt 65536 ]]; then - return 0 - fi - return 1 -} - -function check_port_ready() -{ - # Usage: check_port_active PORT PORT_NAME - port_num="${1}" - port_check=$(lsof -P "-i:${port_num}" | grep "LISTEN" || true) - if [[ -z "${port_check}" ]]; then - echo "Error: ${2} port (${port_num}) is not ready - is the Baas proxy running?" - exit 1 - fi - if ! curl "${TOXIPROXY_URL}/version" --silent --fail --connect-timeout 10 > /dev/null; then - echo "Error: No response from ${2} (${port_num}) - is the Baas proxy running?" - exit 1 - fi -} - -function parse_random() -{ - # Usage: parse_random RANDOM_STRING => RND_MIN, RND_MAX - random_string="${1}" - old_ifs="${IFS}" - - RND_MIN=() - RND_MAX=() - - if [[ "${random_string}" =~ .*|.* ]]; then - IFS='|' - read -ra random_list <<< "${random_string}" - else - random_list=("${random_string}") - fi - for random in "${random_list[@]}" - do - if [[ ! "${random}" =~ .*:.* ]]; then - IFS="${old_ifs}" - return 1 - fi - - # Setting IFS (input field separator) value as ":" and read the split string into array - IFS=':' - read -ra rnd_arr <<< "${random}" - - if [[ ${#rnd_arr[@]} -ne 2 ]]; then - IFS="${old_ifs}" - return 1 - elif [[ -z "${rnd_arr[0]}" || -z "${rnd_arr[0]}" ]]; then - IFS="${old_ifs}" - return 1 - fi - - if [[ ${rnd_arr[0]} -le ${rnd_arr[1]} ]]; then - RND_MIN+=("${rnd_arr[0]}") - RND_MAX+=("${rnd_arr[1]}") - else - RND_MIN+=("${rnd_arr[1]}") - RND_MAX+=("${rnd_arr[0]}") - fi - done - IFS="${old_ifs}" - return 0 -} - -function generate_random() -{ - # Usage: generate_random MINVAL MAXVAL => RAND_VAL - minval="${1}" - maxval="${2}" - diff=$(( "${maxval}" - "${minval}" )) - if [[ ${diff} -gt ${RND_DIFF} ]]; then - return 1 - fi - RAND_VAL=$(( "$minval" + $(("$RANDOM" % "$diff")) )) -} - -# Wait until after the functions are configured before enabling verbose tracing -if [[ -n "${VERBOSE}" ]]; then - set -o verbose - set -o xtrace -fi - -if ! check_port "${CONFIG_PORT}"; then - echo "Error: Baas proxy HTTP API config port was invalid: '${CONFIG_PORT}'" - usage 1 -fi - -# Parse and verify the random string, if provided -if [[ -n "${RND_STRING}" ]]; then - if ! parse_random "${RND_STRING}"; then - echo "Error: Malformed random string: ${random_string} - format 'MIN:MAX[|MIN:MAX[|...]]" - usage 1 - fi -fi - -# Verify the Baas proxy is ready to roll -check_port_ready "${CONFIG_PORT}" "Baas proxy HTTP API config" - -# Create a temp directory for constructing the updated config file -CONFIG_TMP_DIR=$(mktemp -d -t "proxy-config.XXXXXX") -cp "${PROXY_JSON_FILE}" "${CONFIG_TMP_DIR}" -json_file="$(basename "${PROXY_JSON_FILE}")" -TMP_CONFIG="${CONFIG_TMP_DIR}/${json_file}" - -if [[ ${#RND_MIN[@]} -gt 0 ]]; then - cnt=0 - while [[ cnt -lt ${#RND_MIN[@]} ]]; do - rndmin=${RND_MIN[cnt]} - rndmax=${RND_MAX[cnt]} - if ! generate_random "${rndmin}" "${rndmax}"; then - echo "Error: MAX - MIN cannot be more than ${RND_DIFF}" - exit 1 - fi - - cnt=$((cnt + 1)) - printf "Generated random value #%d from %d to %d: %d\n" "${cnt}" "${rndmin}" "${rndmax}" "${RAND_VAL}" - sed_pattern=$(printf "s/%%RANDOM%d%%/%d/g" "${cnt}" "${RAND_VAL}") - sed -i.bak "${sed_pattern}" "${TMP_CONFIG}" - done -fi - -# Get the current list of configured toxics for the baas_proxy proxy -TOXICS=$(${CURL} --silent "${TOXIPROXY_URL}/proxies/${PROXY_NAME}/toxics") -if [[ "${TOXICS}" != "[]" ]]; then - # Extract the toxic names from the toxics list JSON - # Steps: Remove brackets, split into lines, extract "name" value - mapfile -t TOXIC_LIST < <(echo "${TOXICS}" | sed 's/\[\(.*\)\]/\1/g' | sed 's/},{/}\n{/g' | sed 's/.*"name":"\([^"]*\).*/\1/g') - echo "Clearing existing set of toxics (${#TOXIC_LIST[@]}) for ${PROXY_NAME} proxy" - for toxic in "${TOXIC_LIST[@]}" - do - ${CURL} -X DELETE "${TOXIPROXY_URL}/proxies/${PROXY_NAME}/toxics/${toxic}" - done -fi - -# Configure the new set of toxics for the baas_proxy proxy -echo "Configuring toxics for ${PROXY_NAME} proxy with file: ${json_file}" -while IFS= read -r line; do - ${CURL} -X POST -H "Content-Type: application/json" --silent -d "${line}" "${TOXIPROXY_URL}/proxies/${PROXY_NAME}/toxics" > /dev/null -done < "${TMP_CONFIG}" diff --git a/evergreen/proxy-network-faults.toxics b/evergreen/proxy-network-faults.toxics deleted file mode 100644 index 8168089606c..00000000000 --- a/evergreen/proxy-network-faults.toxics +++ /dev/null @@ -1,4 +0,0 @@ -{"name": "limit-data-upstream","type": "limit_data","stream": "upstream","toxicity": 0.6,"attributes": {"bytes": %RANDOM1%}} -{"name": "limit-data-downstream","type": "limit_data","stream": "downstream","toxicity": 0.6,"attributes": {"bytes": %RANDOM2%}} -{"name": "slow-close-upstream","type": "slow_close","stream": "upstream","toxicity": 0.6,"attributes": {"delay": %RANDOM3%}} -{"name": "reset-peer-upstream","type": "reset_peer","stream": "upstream","toxicity": 0.6,"attributes": {"timeout": %RANDOM4%}} diff --git a/evergreen/proxy-nonideal-transfer.toxics b/evergreen/proxy-nonideal-transfer.toxics deleted file mode 100644 index c0ff2d4b9b1..00000000000 --- a/evergreen/proxy-nonideal-transfer.toxics +++ /dev/null @@ -1,5 +0,0 @@ -{"name": "latency-upstream","type": "latency","stream": "upstream","toxicity": 0.5,"attributes": {"latency": 250,"jitter": 250}} -{"name": "latency-downstream","type": "latency","stream": "downstream","toxicity": 0.5,"attributes": {"latency": 0,"jitter": 250}} -{"name": "bandwidth-upstream","type": "bandwidth","stream": "upstream","toxicity": 0.5,"attributes": {"rate": %RANDOM1%}} -{"name": "bandwidth-downstream","type": "bandwidth","stream": "downstream","toxicity": 0.5,"attributes": {"rate": %RANDOM2%}} -{"name": "slicer-downstream","type": "slicer","stream": "downstream","toxicity": 0.5,"attributes": {"average_size": 500,"size_variation": 250,"delay": 10000}} diff --git a/evergreen/setup_baas_host.sh b/evergreen/setup_baas_host.sh deleted file mode 100755 index e1d850b5e27..00000000000 --- a/evergreen/setup_baas_host.sh +++ /dev/null @@ -1,279 +0,0 @@ -#!/usr/bin/env bash -# The script to be run on the ubuntu host that will run baas for the evergreen windows tests -# -# Usage: -# ./evergreen/setup_baas_host.sh [-b BRANCH] [-d PATH] [-t PORT] [-v] [-h] HOST_VARS -# - -set -o errexit -set -o errtrace -set -o pipefail - -trap 'catch $? ${LINENO}' ERR -trap "exit" INT TERM - -# Set up catch function that runs when an error occurs -function catch() -{ - # Usage: catch EXIT_CODE LINE_NUM - echo "${BASH_SOURCE[0]}: $2: Error $1 occurred while starting remote baas" -} - -function usage() -{ - # Usage: usage [EXIT_CODE] - echo "Usage: setup_baas_host.sh [-b BRANCH] [-d PATH] [-t PORT] [-v] [-h] HOST_VARS" - echo -e "\tHOST_VARS\tPath to baas host vars script file" - echo "Options:" - echo -e "\t-b BRANCH\tOptional branch or git spec of baas to checkout/build" - echo -e "\t-d PATH\t\tSkip setting up the data device and use alternate data path" - echo -e "\t-v\t\tEnable verbose script debugging" - echo -e "\t-h\t\tShow this usage summary and exit" - echo "ToxiProxy Options:" - echo -e "\t-t PORT\t\tEnable Toxiproxy support (proxy between baas on :9090 and PORT)" - # Default to 0 if exit code not provided - exit "${1:0}" -} - -BAAS_BRANCH= -OPT_DATA_DIR= -PROXY_PORT= -VERBOSE= - -while getopts "b:d:t:vh" opt; do - case "${opt}" in - b) BAAS_BRANCH="${OPTARG}";; - d) if [[ -z "${OPTARG}" ]]; then - echo "Error: Alternate data directory was empty" - usage 1 - fi; OPT_DATA_DIR="${OPTARG}";; - t) if [[ -z "${OPTARG}" ]]; then - echo "Error: Baas proxy port was empty"; - usage 1 - fi; PROXY_PORT="${OPTARG}";; - v) VERBOSE="yes";; - h) usage 0;; - *) usage 1;; - esac -done - -shift $((OPTIND - 1)) - -if [[ $# -lt 1 ]]; then - echo "Error: Baas host vars script not provided" - usage 1 -fi - -BAAS_HOST_VARS="${1}"; shift; - -if [[ -z "${BAAS_HOST_VARS}" ]]; then - echo "Error: Baas host vars script value was empty" - usage 1 -elif [[ ! -f "${BAAS_HOST_VARS}" ]]; then - echo "Error: Baas host vars script not found: ${BAAS_HOST_VARS}" - usage 1 -fi - -# shellcheck disable=SC1090 -source "${BAAS_HOST_VARS}" - -if [[ -z "${AWS_ACCESS_KEY_ID}" ]]; then - echo "Error: AWS_ACCESS_KEY_ID was not provided by baas host vars script" - exit 1 -fi - -if [[ -z "${AWS_SECRET_ACCESS_KEY}" ]]; then - echo "Error: AWS_SECRET_ACCESS_KEY was not provided by baas host vars script" - exit 1 -fi - -if [[ -z "${GITHUB_KNOWN_HOSTS}" ]]; then - # Use a default if not defined, but this may become outdated one day... - GITHUB_KNOWN_HOSTS="github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=" - echo "Info: GITHUB_KNOWN_HOSTS not defined in baas host vars script - using default" -fi -KNOWN_HOSTS_FILE="${HOME}/.ssh/known_hosts" -if [[ -f "${KNOWN_HOSTS_FILE}" ]] && grep "${GITHUB_KNOWN_HOSTS}" < "${KNOWN_HOSTS_FILE}"; then - echo "Github known hosts entry found - skipping known_hosts update" -else - echo "${GITHUB_KNOWN_HOSTS}" | tee -a "${KNOWN_HOSTS_FILE}" -fi - -function init_data_device() -{ - #Usage: init_data_device - data_device= - - # Find /data ebs device to be mounted - devices=$(sudo lsblk | grep disk | awk '{print $1}') - for device in ${devices}; do - is_data=$(sudo file -s "/dev/${device}" | awk '{print $2}') - if [[ "${is_data}" == "data" ]]; then - data_device="/dev/${device}" - fi - done - - # If a data device was discovered, set up the device - if [[ -n "${data_device}" ]]; then - sudo umount /mnt || true - sudo umount "${data_device}" || true - sudo /sbin/mkfs.xfs -f "${data_device}" - sudo mkdir -p "${DATA_DIR}" - # get uuid of data device - data_uuid=$(sudo blkid | grep "${data_device}" | awk '{print $2}') - echo "Found data device: ${data_device}(${data_uuid})" - echo "${data_uuid} ${DATA_DIR} auto noatime 0 0" | sudo tee -a /etc/fstab - sudo mount "${DATA_DIR}" - echo "Successfully mounted ${data_device} to ${DATA_DIR}" - else - # Otherwise, create a local /data dir - sudo mkdir -p "${DATA_DIR}" - fi - - sudo chmod 777 "${DATA_DIR}" -} - -function setup_data_dir() -{ - # Usage: setup_data_dir - # Data directory is expected to be set in DATA_DIR variable - # Delete /data/baas-remote/ dir if is already exists - [[ -d "${BAAS_REMOTE_DIR}" ]] && sudo rm -rf "${BAAS_REMOTE_DIR}" - - # Create the baseline baas remote directories and set perms - DIR_PERMS="$(id -u):$(id -g)" - echo "Creating and setting ${BAAS_REMOTE_DIR} to '${DIR_PERMS}'" - mkdir -p "${BAAS_REMOTE_DIR}" - chown -R "${DIR_PERMS}" "${BAAS_REMOTE_DIR}" - chmod -R 755 "${BAAS_REMOTE_DIR}" - mkdir -p "${BAAS_WORK_DIR}" - chmod -R 755 "${BAAS_WORK_DIR}" - - # Set up the temp directory - it may already exist on evergreen spawn hosts - if [[ -d "${DATA_TEMP_DIR}" ]]; then - sudo chmod 1777 "${DATA_TEMP_DIR}" - else - mkdir -p "${DATA_TEMP_DIR}" - chmod 1777 "${DATA_TEMP_DIR}" - fi - export TMPDIR="${DATA_TEMP_DIR}" -} - -function on_exit() -{ - # Usage: on_exit - baas_pid= - proxy_pid= - if [[ -f "${PROXY_PID_FILE}" ]]; then - proxy_pid="$(< "${PROXY_PID_FILE}")" - fi - - if [[ -f "${SERVER_PID_FILE}" ]]; then - baas_pid="$(< "${SERVER_PID_FILE}")" - fi - - if [[ -n "${proxy_pid}" ]]; then - echo "Stopping baas proxy ${proxy_pid}" - kill "${proxy_pid}" || true - rm -f "${PROXY_PID_FILE}" || true - fi - - if [[ -n "${baas_pid}" ]]; then - echo "Stopping baas server ${baas_pid}" - kill "${baas_pid}" || true - rm -f "${SERVER_PID_FILE}" || true - fi - - echo "Waiting for processes to exit" - wait -} - -function start_baas_proxy() -{ - # Usage: start_baas_proxy PORT - listen_port="${1}" - # Delete the toxiproxy working directory if it currently exists - if [[ -n "${BAAS_PROXY_DIR}" && -d "${BAAS_PROXY_DIR}" ]]; then - rm -rf "${BAAS_PROXY_DIR}" - fi - - if [[ -f "${HOME}/setup_baas_proxy.sh" ]]; then - cp "${HOME}/setup_baas_proxy.sh" evergreen/ - fi - - proxy_options=("-w" "${BAAS_PROXY_DIR}" "-s" "${BAAS_WORK_DIR}" "-p" "${listen_port}") - if [[ -n "${VERBOSE}" ]]; then - proxy_options=("-v") - fi - - # Pass the baas work directory to the toxiproxy script for the go executable - echo "Staring baas proxy with listen port :${listen_port}" - ./evergreen/setup_baas_proxy.sh "${proxy_options[@]}" 2>&1 & - echo $! > "${PROXY_PID_FILE}" -} - - -# Wait until after the BAAS_HOST_VARS file is loaded to enable verbose tracing -if [[ -n "${VERBOSE}" ]]; then - set -o verbose - set -o xtrace -fi - -sudo chmod 600 "${HOME}/.ssh"/* - -# Should an alternate data directory location be used? If so, don't init the data device -if [[ -z "${OPT_DATA_DIR}" ]]; then - DATA_DIR=/data - init_data_device -else - DATA_DIR="${OPT_DATA_DIR}" -fi - -DATA_TEMP_DIR="${DATA_DIR}/tmp" -BAAS_REMOTE_DIR="${DATA_DIR}/baas-remote" -BAAS_WORK_DIR="${BAAS_REMOTE_DIR}/baas-work-dir" -SERVER_PID_FILE="${BAAS_REMOTE_DIR}/baas-server.pid" -BAAS_STOPPED_FILE="${BAAS_WORK_DIR}/baas_stopped" - -BAAS_PROXY_DIR="${BAAS_REMOTE_DIR}/baas-proxy-dir" -PROXY_PID_FILE="${BAAS_REMOTE_DIR}/baas-proxy.pid" -PROXY_STOPPED_FILE="${BAAS_PROXY_DIR}/baas_proxy_stopped" - -setup_data_dir - -pushd "${BAAS_REMOTE_DIR}" > /dev/null - -if [[ -d "${HOME}/remote-baas/evergreen/" ]]; then - cp -R "${HOME}/remote-baas/evergreen/" ./evergreen/ -else - echo "remote-baas/evergreen/ directory not found in ${HOME}" - exit 1 -fi - -# Set up the cleanup function that runs at exit and stops baas server and proxy (if run) -trap 'on_exit' EXIT - -BAAS_OPTIONS=() -if [[ -n "${BAAS_BRANCH}" ]]; then - BAAS_OPTIONS=("-b" "${BAAS_BRANCH}") -fi -if [[ -n "${VERBOSE}" ]]; then - BAAS_OPTIONS+=("-v") -fi - -echo "Staring baas server..." -./evergreen/install_baas.sh "${BAAS_OPTIONS[@]}" -w "${BAAS_WORK_DIR}" 2>&1 & -echo $! > "${SERVER_PID_FILE}" - -if [[ -n "${PROXY_PORT}" ]]; then - start_baas_proxy "${PROXY_PORT}" -fi - -# Turn off verbose logging since it's so noisy -set +o verbose -set +o xtrace -until [[ -f "${BAAS_STOPPED_FILE}" || -f "${PROXY_STOPPED_FILE}" ]]; do - sleep 1 -done - -popd > /dev/null # /data/baas-remote diff --git a/evergreen/setup_baas_host_local.sh b/evergreen/setup_baas_host_local.sh deleted file mode 100755 index d1cc4e907e4..00000000000 --- a/evergreen/setup_baas_host_local.sh +++ /dev/null @@ -1,269 +0,0 @@ -#!/usr/bin/env bash -# The script to be run on the ubuntu host that will run baas for the evergreen windows tests -# -# Usage: -# ./evergreen/setup_baas_host_local.sh [-w PATH] [-u USER] [-b BRANCH] [-v] [-h] [-t] [-d PORT] [-l PORT] [-c PORT] HOST_VARS SSH_KEY -# - -set -o errexit -set -o errtrace -set -o pipefail - -EVERGREEN_PATH=./evergreen -BAAS_WORK_PATH=./baas-work-dir -BAAS_HOST_NAME= -BAAS_USER=ubuntu -BAAS_BRANCH= -VERBOSE= -BAAS_PROXY= -DIRECT_PORT=9098 -LISTEN_PORT=9092 -CONFIG_PORT=8474 -BAAS_PORT=9090 -BAAS_HOST_KEY= - -function usage() -{ - echo "Usage: setup_baas_host_local.sh [-w PATH] [-u USER] [-b BRANCH] [-v] [-h] [-t] [-d PORT] [-l PORT] [-c PORT] [-i SSH_KEY] HOST_VARS" - echo -e "\tHOST_VARS\tPath to baas host vars script file" - echo -e "\t -i SSH_KEY\t\tPath to baas host private key file" - echo "Options:" - echo -e "\t-w PATH\t\tPath to local baas server working directory (default ${BAAS_WORK_PATH})" - echo -e "\t-u USER\t\tUsername to connect to baas host (default ${BAAS_USER})" - echo -e "\t-b BRANCH\tOptional branch or git spec of baas to checkout/build" - echo -e "\t-v\t\tEnable verbose script debugging" - echo -e "\t-h\t\tShow this usage summary and exit" - echo "Baas Proxy Options:" - echo -e "\t-t\t\tEnable baas proxy support (proxy between baas on :9090 and listen port)" - echo -e "\t-d PORT\t\tPort for direct connection to baas - skips proxy (default ${DIRECT_PORT})" - echo -e "\t-l PORT\t\tBaas proxy listen port on remote host (default ${LISTEN_PORT})" - echo -e "\t-c PORT\t\tLocal configuration port for proxy HTTP API (default ${CONFIG_PORT})" - echo "Note: This script must be run from a cloned realm-core/ repository directory." - # Default to 0 if exit code not provided - exit "${1:0}" -} - -while getopts "w:u:b:ta:d:l:c:vhi:" opt; do - case "${opt}" in - w) BAAS_WORK_PATH="${OPTARG}";; - u) BAAS_USER="${OPTARG}";; - b) BAAS_BRANCH="${OPTARG}";; - t) BAAS_PROXY="yes";; - d) DIRECT_PORT="${OPTARG}";; - l) LISTEN_PORT="${OPTARG}";; - c) CONFIG_PORT="${OPTARG}";; - i) BAAS_HOST_KEY="${OPTARG}";; - v) VERBOSE="yes";; - h) usage 0;; - *) usage 1;; - esac -done - -shift $((OPTIND - 1)) - -if [[ $# -lt 1 ]]; then - echo "Error: Baas host vars script not provided" - usage 1 -fi -BAAS_HOST_VARS="${1}"; shift; - -if [[ -z "${BAAS_HOST_VARS}" ]]; then - echo "Error: Baas host vars script value was empty" - usage 1 -elif [[ ! -f "${BAAS_HOST_VARS}" ]]; then - echo "Error: Baas host vars script not found: ${BAAS_HOST_VARS}" - usage 1 -fi - -if [[ -n "${BAAS_HOST_KEY}" && ! -f "${BAAS_HOST_KEY}" ]]; then - echo "Error: Baas host private key not found: ${BAAS_HOST_KEY}" - usage 1 -fi - -if [[ "${BAAS_USER}" = "root" ]]; then - FILE_DEST_DIR="/root/remote-baas" -else - FILE_DEST_DIR="/home/${BAAS_USER}/remote-baas" -fi -EVERGREEN_DEST_DIR="${FILE_DEST_DIR}/evergreen" - -function check_port() -{ - # Usage check_port PORT - port_num="${1}" - if [[ -n "${port_num}" && ${port_num} -gt 0 && ${port_num} -lt 65536 ]]; then - return 0 - fi - return 1 -} - -function check_port_in_use() -{ - # Usage: check_port_in_use PORT PORT_NAME - port_num="${1}" - port_check=$(lsof -P "-i:${port_num}" | grep "LISTEN" || true) - if [[ -n "${port_check}" ]]; then - echo "Error: ${2} port (${port_num}) is already in use" - echo -e "${port_check}" - exit 1 - fi -} - -# Check the local baas port availability -check_port_in_use "${BAAS_PORT}" "Local baas server" - -# Check the port values and local ports in use for baas proxy -if [[ -n "${BAAS_PROXY}" ]]; then - if ! check_port "${CONFIG_PORT}"; then - echo "Error: Baas proxy local HTTP API config port was invalid: '${CONFIG_PORT}'" - usage 1 - elif ! check_port "${LISTEN_PORT}"; then - echo "Error: Baas proxy listen port was invalid: '${LISTEN_PORT}'" - usage 1 - fi - check_port_in_use "${CONFIG_PORT}" "Local baas proxy config" - - if [[ -n "${DIRECT_PORT}" ]]; then - if ! check_port "${DIRECT_PORT}"; then - echo "Error: Baas direct connect port was invalid: '${DIRECT_PORT}'" - usage 1 - fi - check_port_in_use "${DIRECT_PORT}" "Local baas server direct connect" - fi -fi - -trap 'catch $? ${LINENO}' ERR -trap 'on_exit' INT TERM EXIT - -# Set up catch function that runs when an error occurs -function catch() -{ - # Usage: catch EXIT_CODE LINE_NUM - echo "${BASH_SOURCE[0]}: $2: Error $1 occurred while starting baas (local)" -} - -function on_exit() -{ - # Usage: on_exit - if [[ -n "${BAAS_WORK_PATH}" ]]; then - # Create the baas_stopped file so wait_for_baas can exit early - [[ -d "${BAAS_WORK_PATH}" ]] || mkdir -p "${BAAS_WORK_PATH}" - touch "${BAAS_WORK_PATH}/baas_stopped" - fi -} - -# shellcheck disable=SC1090 -source "${BAAS_HOST_VARS}" - -# Wait until after the BAAS_HOST_VARS file is loaded to enable verbose tracing -if [[ -n "${VERBOSE}" ]]; then - set -o verbose - set -o xtrace -fi - -if [[ -z "${BAAS_HOST_NAME}" ]]; then - echo "Baas remote hostname (BAAS_HOST_NAME) not provided in baas host vars script" - usage 1 -fi - -if [[ -z "${BAAS_USER}" ]]; then - echo "Error: Baas host username was empty" - usage 1 -fi - -if [[ ! -d "${EVERGREEN_PATH}/" ]]; then - echo "This script must be run from the realm-core directory for accessing files in '${EVERGREEN_PATH}/'" - exit 1 -fi - -SSH_USER="$(printf "%s@%s" "${BAAS_USER}" "${BAAS_HOST_NAME}")" - -SSH_OPTIONS=(-o ForwardAgent=yes -o StrictHostKeyChecking=no ) -if [[ -n "${BAAS_HOST_KEY}" ]]; then - ssh-agent > ssh_agent_commands.sh - - # shellcheck disable=SC1091 - source ssh_agent_commands.sh - - if [[ -f ~/.ssh/id_rsa ]]; then - ssh-add ~/.ssh/id_rsa - fi - - ssh-add "${BAAS_HOST_KEY}" - SSH_OPTIONS+=(-o IdentitiesOnly=yes -i "${BAAS_HOST_KEY}") -fi - -echo "running ssh with ${SSH_OPTIONS[*]}" - -RETRY_COUNT=25 -WAIT_COUNTER=0 -WAIT_START=$(date -u +'%s') -CONNECT_COUNT=2 - -# Check for remote connectivity - try to connect twice to verify server is "really" ready -# The tests failed one time due to this ssh command passing, but the next scp command failed -while [[ ${CONNECT_COUNT} -gt 0 ]]; do - until ssh "${SSH_OPTIONS[@]}" -o ConnectTimeout=10 "${SSH_USER}" "mkdir -p ${EVERGREEN_DEST_DIR} && echo -n 'hello from '; hostname" ; do - if [[ ${WAIT_COUNTER} -ge ${RETRY_COUNT} ]] ; then - secs_spent_waiting=$(($(date -u +'%s') - WAIT_START)) - echo "Timed out after waiting ${secs_spent_waiting} seconds for host ${BAAS_HOST_NAME} to start" - exit 1 - fi - - ((++WAIT_COUNTER)) - printf "SSH connection attempt %d/%d failed. Retrying...\n" "${WAIT_COUNTER}" "${RETRY_COUNT}" - sleep 10 - done - - ((CONNECT_COUNT--)) -done - -echo "Transferring setup scripts to ${SSH_USER}:${FILE_DEST_DIR}" -# Copy the baas host vars script to the baas remote host -scp "${SSH_OPTIONS[@]}" -o ConnectTimeout=60 "${BAAS_HOST_VARS}" "${SSH_USER}:${FILE_DEST_DIR}/" -# Copy the entire evergreen/ directory from the working copy of realm-core to the remote host -# This ensures the remote host the latest copy, esp when running evergreen patches -# dependencies.yml contains the BAAS_VERSION to use -echo "Transferring evergreen scripts to ${SSH_USER}:${FILE_DEST_DIR}" -cp "${EVERGREEN_PATH}/../dependencies.yml" "${EVERGREEN_PATH}/" -scp -r "${SSH_OPTIONS[@]}" -o ConnectTimeout=60 "${EVERGREEN_PATH}/" "${SSH_USER}:${FILE_DEST_DIR}/" - -BAAS_TUNNELS=() -SETUP_OPTIONS=() - -if [[ -n "${VERBOSE}" ]]; then - SETUP_OPTIONS+=("-v") -fi - -if [[ -n "${BAAS_PROXY}" ]]; then - # Add extra tunnel for baas proxy HTTP API config interface and direct connection to baas - BAAS_TUNNELS+=("-L" "${CONFIG_PORT}:127.0.0.1:8474") - if [[ -n "${DIRECT_PORT}" ]]; then - BAAS_TUNNELS+=("-L" "${DIRECT_PORT}:127.0.0.1:9090") - fi - # Enable baas proxy and use LISTEN_PORT as the proxy listen port - SETUP_OPTIONS+=("-t" "${LISTEN_PORT}") -else - # Force remote port to 9090 if baas proxy is not used - connect directly to baas - LISTEN_PORT=9090 -fi - -BAAS_TUNNELS+=("-L" "9090:127.0.0.1:${LISTEN_PORT}") - -# Run the setup baas host script and provide the location of the baas host vars script -# Also sets up a forward tunnel for local port 9090 through the ssh connection to the baas remote host -# If baas proxy is enabled, a second forward tunnel is added for the HTTP API config interface -echo "Running setup script (with forward tunnel on :9090 to 127.0.0.1:${LISTEN_PORT})" -if [[ -n "${BAAS_BRANCH}" ]]; then - echo "- Starting remote baas with branch/commit: '${BAAS_BRANCH}'" - SETUP_OPTIONS+=("-b" "${BAAS_BRANCH}") -fi -if [[ -n "${BAAS_PROXY}" ]]; then - echo "- Baas proxy enabled - local HTTP API config port on :${CONFIG_PORT}" - if [[ -n "${DIRECT_PORT}" ]]; then - echo "- Baas direct connection on port :${DIRECT_PORT}" - fi -fi - -ssh -t "${SSH_OPTIONS[@]}" -o ConnectTimeout=60 "${BAAS_TUNNELS[@]}" "${SSH_USER}" \ - "${EVERGREEN_DEST_DIR}/setup_baas_host.sh" "${SETUP_OPTIONS[@]}" "${FILE_DEST_DIR}/baas_host_vars.sh" diff --git a/evergreen/setup_baas_proxy.sh b/evergreen/setup_baas_proxy.sh deleted file mode 100755 index 8a5d1ba4443..00000000000 --- a/evergreen/setup_baas_proxy.sh +++ /dev/null @@ -1,263 +0,0 @@ -#!/usr/bin/env bash -# The script to download, build and run toxiproxy as a proxy to the baas server -# for simulating network error conditions for testing. -# -# Usage: -# ./evergreen/setup_baas_proxy.sh -w PATH [-p PORT] [-s PATH] [-b BRANCH] [-d] [-v] [-h] -# - -set -o errexit -set -o errtrace -set -o pipefail - -trap 'catch $? ${LINENO}' ERR -trap "exit" INT TERM - -function catch() -{ - echo "Error $1 occurred while starting baas proxy at line $2" -} - -WORK_PATH= -BAAS_PATH= -TOXIPROXY_VERSION="v2.5.0" -LISTEN_PORT=9092 -BAAS_PORT=9090 -SKIP_BAAS_WAIT= -CONFIG_PORT=8474 - -function usage() -{ - echo "Usage: setup_baas_proxy.sh -w PATH [-p PORT] [-s PATH] [-b BRANCH] [-d] [-v] [-h]" - echo -e "\t-w PATH\t\tPath to baas proxy working directory" - echo "Options:" - echo -e "\t-p PORT\t\tListen port for proxy connected to baas (default: ${LISTEN_PORT})" - echo -e "\t-s PATH\t\tOptional path to baas server working directory (for go binary)" - echo -e "\t-b BRANCH\tOptional branch or git spec to checkout/build (default: ${TOXIPROXY_VERSION})" - echo -e "\t-d\t\tDon't wait for baas to start before starting proxy" - echo -e "\t-v\t\tEnable verbose script debugging" - echo -e "\t-h\t\tShow this usage summary and exit" - # Default to 0 if exit code not provided - exit "${1:0}" -} - -BASE_PATH="$(cd "$(dirname "$0")"; pwd)" - -# Allow path to CURL to be overloaded by an environment variable -CURL="${CURL:=$LAUNCHER curl}" - -while getopts "w:p:s:b:dvh" opt; do - case "${opt}" in - w) WORK_PATH="${OPTARG}";; - p) LISTEN_PORT="${OPTARG}";; - s) BAAS_PATH="${OPTARG}";; - b) TOXIPROXY_VERSION="${OPTARG}";; - d) SKIP_BAAS_WAIT="yes";; - v) set -o verbose; set -o xtrace;; - h) usage 0;; - *) usage 1;; - esac -done - -if [[ -z "${WORK_PATH}" ]]; then - echo "Baas proxy work path was not provided" - usage 1 -fi -if [[ -z "${LISTEN_PORT}" ]]; then - echo "Baas proxy remote port was empty" - usage 1 -fi - -function check_port_in_use() -{ - # Usage: check_port_in_use PORT PORT_NAME - port_num="${1}" - port_check=$(lsof -P "-i:${port_num}" | grep "LISTEN" || true) - if [[ -n "${port_check}" ]]; then - echo "Error: ${2} port (${port_num}) is already in use" - echo -e "${port_check}" - exit 1 - fi -} - -# Check the baas proxy listen and Toxiproxy config port availability first -check_port_in_use "${LISTEN_PORT}" "baas proxy" -check_port_in_use "${CONFIG_PORT}" "Toxiproxy config" - -[[ -d "${WORK_PATH}" ]] || mkdir -p "${WORK_PATH}" -pushd "${WORK_PATH}" > /dev/null - -PROXY_CFG_FILE="${WORK_PATH}/baas_proxy.json" -PROXY_LOG="${WORK_PATH}/baas_proxy.log" -PROXY_PID_FILE="${WORK_PATH}/baas_proxy.pid" -PROXY_STOPPED_FILE="${WORK_PATH}/baas_proxy_stopped" -BAAS_STOPPED_FILE="${BAAS_PATH}/baas_stopped" - -# Remove some files from a previous run if they exist -if [[ -f "${CONFIG_FILE}" ]]; then - rm -f "${CONFIG_FILE}" -fi -if [[ -f "${PROXY_LOG}" ]]; then - rm -f "${PROXY_LOG}" -fi -if [[ -f "${PROXY_PID_FILE}" ]]; then - rm -f "${PROXY_PID_FILE}" -fi - -if [[ -f "${PROXY_STOPPED}" ]]; then - rm -f "${PROXY_STOPPED}" -fi - -# Set up the cleanup function that runs at exit and stops the toxiproxy server -trap 'on_exit' EXIT - -function on_exit() -{ - # Usage: on_exit - # Toxiproxy is being stopped (or never started), create a 'baas-proxy-stopped' file - touch "${PROXY_STOPPED_FILE}" || true - - proxy_pid= - if [[ -f "${PROXY_PID_FILE}" ]]; then - proxy_pid="$(< "${PROXY_PID_FILE}")" - fi - - if [[ -n "${proxy_pid}" ]]; then - echo "Stopping baas proxy ${proxy_pid}" - kill "${proxy_pid}" || true - echo "Waiting for baas proxy to stop" - wait - rm -f "${PROXY_PID_FILE}" || true - fi -} - -case $(uname -s) in - Darwin) - if [[ "$(uname -m)" == "arm64" ]]; then - export GOARCH=arm64 - GO_URL="https://s3.amazonaws.com/static.realm.io/evergreen-assets/go1.19.3.darwin-arm64.tar.gz" - # Go's scheduler is not BIG.little aware, and by default will spawn - # threads until they end up getting scheduled on efficiency cores, - # which is slower than just not using them. Limiting the threads to - # the number of performance cores results in them usually not - # running on efficiency cores. Checking the performance core count - # wasn't implemented until the first CPU with a performance core - # count other than 4 was released, so if it's unavailable it's 4. - GOMAXPROCS="$(sysctl -n hw.perflevel0.logicalcpu || echo 4)" - export GOMAXPROCS - else - export GOARCH=amd64 - GO_URL="https://s3.amazonaws.com/static.realm.io/evergreen-assets/go1.19.1.darwin-amd64.tar.gz" - fi - ;; - Linux) - GO_URL="https://s3.amazonaws.com/static.realm.io/evergreen-assets/go1.19.1.linux-amd64.tar.gz" - ;; -esac - -# Looking for go - first in the work path, then in the baas path (if provided), or -# download go into the work path -GOROOT= -# Was it found in the work path? -if [[ ! -x ${WORK_PATH}/go/bin/go ]]; then - # If the baas work path is set, check there first and wait - if [[ -n "${BAAS_PATH}" && -d "${BAAS_PATH}" ]]; then - WAIT_COUNTER=0 - RETRY_COUNT=10 - WAIT_START=$(date -u +'%s') - FOUND_GO="yes" - GO_ROOT_FILE="${BAAS_PATH}/go_root" - # Bass may be initializing at the same time, allow a bit of time for the two to sync - echo "Looking for go in baas work path for 20 secs in case both are starting concurrently" - until [[ -f "${GO_ROOT_FILE}" ]]; do - if [[ -n "${BAAS_STOPPED_FILE}" && -f "${BAAS_STOPPED_FILE}" ]]; then - echo "Error: Baas server failed to start (found baas_stopped file)" - exit 1 - fi - if [[ ${WAIT_COUNTER} -ge ${RETRY_COUNT} ]]; then - FOUND_GO= - secs_spent_waiting=$(($(date -u +'%s') - WAIT_START)) - echo "Error: Stopped after waiting ${secs_spent_waiting} seconds for baas go to become available" - break - fi - ((++WAIT_COUNTER)) - sleep 2 - done - if [[ -n "${FOUND_GO}" ]]; then - GOROOT="$(cat "${GO_ROOT_FILE}")" - echo "Found go in baas working directory: ${GOROOT}" - export GOROOT - fi - fi - - # If GOROOT is not set, then baas path was nor provided or go was not found - if [[ -z "${GOROOT}" ]]; then - # Download go since it wasn't found in the working directory - if [[ -z "${GO_URL}" ]]; then - echo "Error: go url not defined for current OS architecture" - uname -a - exit 1 - fi - echo "Downloading go to baas proxy working directory" - ${CURL} -sL "${GO_URL}" | tar -xz - # Set up the GOROOT for building/running baas - export GOROOT="${WORK_PATH}/go" - fi -else - echo "Found go in baas proxy working directory" - # Set up the GOROOT for building/running baas - export GOROOT="${WORK_PATH}/go" -fi -export PATH="${GOROOT}/bin":${PATH} -echo "Go version: $(go version)" - -if [[ ! -d "toxiproxy" ]]; then - git clone git@github.com:Shopify/toxiproxy.git toxiproxy -fi - -# Clone the baas repo and check out the specified version -if [[ ! -d "toxiproxy/.git" ]]; then - git clone git@github.com:Shopify/toxiproxy.git toxiproxy - pushd toxiproxy > /dev/null -else - pushd toxiproxy > /dev/null - git fetch -fi - -echo "Checking out Toxiproxy version '${TOXIPROXY_VERSION}'" -git checkout "${TOXIPROXY_VERSION}" -echo "Using Toxiproxy commit: $(git rev-parse HEAD)" - -# Build toxiproxy -make build - -if [[ -z "${SKIP_BAAS_WAIT}" ]]; then - # Wait for baas to start before starting Toxiproxy - OPT_WAIT_BAAS=() - if [[ -n "${BAAS_PATH}" ]]; then - OPT_WAIT_BAAS=("-w" "{$BAAS_PATH}") - fi - - "${BASE_PATH}/wait_for_baas.sh" "${OPT_WAIT_BAAS[@]}" -fi - -cat >"${PROXY_CFG_FILE}" < 127.0.0.1:${BAAS_PORT}" -./dist/toxiproxy-server -config "${PROXY_CFG_FILE}" > "${PROXY_LOG}" 2>&1 & -echo $! > "${PROXY_PID_FILE}" - -echo "---------------------------------------------" -echo "Baas proxy ready" -echo "---------------------------------------------" -wait - -popd > /dev/null # toxiproxy -popd > /dev/null # / diff --git a/evergreen/wait_for_baas.sh b/evergreen/wait_for_baas.sh deleted file mode 100755 index 508ec310eca..00000000000 --- a/evergreen/wait_for_baas.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/usr/bin/env bash -# The script to wait up to approx 600 seconds (default) for the baas server to -# start, which is indicated by being able to successfully "curl" the baas -# server endpoint. If a pid file is provided, it will be used to verify the -# baas server is still running. The retry count specifies the number of -# attempts to query the server endpoint, with a 5 sec wait between attempts. -# If a server log path is provided, the last entries will be printed to stdout -# using the 'tail' command after each attempt. -# -# Usage: -# ./evergreen/wait_for_baas.sh [-w PATH] [-p FILE] [-r COUNT] [-l FILE] [-s] [-v] [-h] -# - -set -o errexit -set -o pipefail - -CURL=${CURL:=curl} -BAAS_PID_FILE= -BAAS_STOPPED_FILE= -RETRY_COUNT=120 -BAAS_SERVER_LOG= -STATUS_OUT= - -function usage() -{ - echo "Usage: wait_for_baas.sh [-w PATH] [-p FILE] [-r COUNT] [-l FILE] [-s] [-v] [-h]" - echo "Options:" - echo -e "\t-w PATH\t\tPath to baas server working directory" - echo -e "\t-p FILE\t\tPath to baas server pid file (also set by -w option)" - echo -e "\t-r COUNT\tNumber of attempts to check for baas server (default 120)" - echo -e "\t-l FILE\t\tPath to baas server log file (also set by -w option)" - echo -e "\t-s\t\tDisplay a status for each attempt" - echo -e "\t-v\t\tEnable verbose script debugging" - echo -e "\t-h\t\tShow this usage summary and exit" - # Default to 0 if exit code not provided - exit "${1:0}" -} - -function update_paths() -{ - if [[ -n "${1}" ]]; then - BAAS_SERVER_LOG="${1}/baas_server.log" - BAAS_STOPPED_FILE="${1}/baas_stopped" - BAAS_PID_FILE="${1}/baas_server.pid" - fi -} - -while getopts "w:p:r:l:svh" opt; do - case "${opt}" in - w) update_paths "${OPTARG}";; - p) BAAS_PID_FILE="${OPTARG}";; - r) RETRY_COUNT="${OPTARG}";; - l) BAAS_SERVER_LOG="${OPTARG}";; - s) STATUS_OUT="yes";; - v) set -o verbose; set -o xtrace;; - h) usage 0;; - *) usage 1;; - esac -done - -WAIT_COUNTER=0 -WAIT_START=$(date -u +'%s') - -function output_log_tail() -{ - if [[ -n "${BAAS_SERVER_LOG}" && -f "${BAAS_SERVER_LOG}" ]]; then - tail -n 10 "${BAAS_SERVER_LOG}" - fi -} - -echo "Waiting for baas server to start..." -until $CURL --output /dev/null --head --fail http://localhost:9090 --silent ; do - if [[ -n "${BAAS_STOPPED_FILE}" && -f "${BAAS_STOPPED_FILE}" ]]; then - echo "Baas server failed to start (found baas_stopped file)" - output_log_tail - exit 1 - fi - - if [[ -n "${BAAS_PID_FILE}" && -f "${BAAS_PID_FILE}" ]]; then - if ! pgrep -F "${BAAS_PID_FILE}" > /dev/null; then - echo "Baas server $(< "${BAAS_PID_FILE}") is no longer running" - output_log_tail - exit 1 - fi - fi - - ((++WAIT_COUNTER)) - secs_spent_waiting=$(($(date -u +'%s') - WAIT_START)) - if [[ ${WAIT_COUNTER} -ge ${RETRY_COUNT} ]]; then - echo "Timed out after ${secs_spent_waiting} secs waiting for baas server to start" - output_log_tail - exit 1 - fi - - if [[ -n "${STATUS_OUT}" ]]; then - echo "Waiting for baas server to start... ${secs_spent_waiting} secs so far" - fi - - sleep 5 -done diff --git a/evergreen/wait_for_remote_baas.sh b/evergreen/wait_for_remote_baas.sh deleted file mode 100755 index 3eaf3da5915..00000000000 --- a/evergreen/wait_for_remote_baas.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash -# Wait for baas to be setup on a remote host - -set -o errexit -set -o pipefail - -EVERGREEN_PATH=./evergreen -BAAS_WORK_PATH=./baas-work-dir -BAAS_HOST_NAME= -BAAS_USER=ubuntu -VERBOSE= -BAAS_HOST_KEY= - -function usage() -{ - echo "Usage: wait_for_remote_baas.sh [-v] [-h] [-i SSH_KEY] HOST_VARS" - echo -e "\tHOST_VARS\tPath to baas host vars script file" - echo -e "\t-i SSH_KEY\t\tPath to baas host private key file" - echo "Options:" - echo -e "\t-v\t\tEnable verbose script debugging" - echo -e "\t-h\t\tShow this usage summary and exit" - echo "If an SSH_KEY is not provided, the script will assume an ssh agent is already running with" - echo "an appropriate key" - exit "${1:0}" -} - -while getopts "vhi:" opt; do - case "${opt}" in - v) VERBOSE="yes";; - i) BAAS_HOST_KEY="${OPTARG}";; - h) usage 0;; - *) usage 1;; - esac -done - -shift $((OPTIND - 1)) - -if [[ $# -lt 1 ]]; then - echo "Error: Baas host vars script not provided" - usage 1 -fi -BAAS_HOST_VARS="${1}"; shift; - -if [[ -z "${BAAS_HOST_VARS}" ]]; then - echo "Error: Baas host vars script value was empty" - usage 1 -elif [[ ! -f "${BAAS_HOST_VARS}" ]]; then - echo "Error: Baas host vars script not found: ${BAAS_HOST_VARS}" - usage 1 -fi - -if [[ -n "${BAAS_HOST_KEY}" && ! -f "${BAAS_HOST_KEY}" ]]; then - echo "Error: Baas host private key not found: ${BAAS_HOST_KEY}" - usage 1 -fi - -if [[ "${BAAS_USER}" = "root" ]]; then - FILE_DEST_DIR="/root/remote-baas" -else - FILE_DEST_DIR="/home/${BAAS_USER}/remote-baas" -fi -EVERGREEN_DEST_DIR="${FILE_DEST_DIR}/evergreen" - -# shellcheck disable=SC1090 -source "${BAAS_HOST_VARS}" - -# Wait until after the BAAS_HOST_VARS file is loaded to enable verbose tracing -if [[ -n "${VERBOSE}" ]]; then - set -o verbose - set -o xtrace -fi - -if [[ -z "${BAAS_HOST_NAME}" ]]; then - echo "Baas remote hostname (BAAS_HOST_NAME) not provided in baas host vars script" - usage 1 -fi - -if [[ -z "${BAAS_USER}" ]]; then - echo "Error: Baas host username was empty" - usage 1 -fi - -if [[ ! -d "${EVERGREEN_PATH}/" ]]; then - echo "This script must be run from the realm-core directory for accessing files in '${EVERGREEN_PATH}/'" - exit 1 -fi - -SSH_USER="$(printf "%s@%s" "${BAAS_USER}" "${BAAS_HOST_NAME}")" -SSH_OPTIONS=(-o ForwardAgent=yes -o StrictHostKeyChecking=no) - -if [[ -n "${BAAS_HOST_KEY}" ]]; then - ssh-agent > ssh_agent_commands.sh - - # shellcheck disable=SC1091 - source ssh_agent_commands.sh - - ssh-add "${BAAS_HOST_KEY}" - SSH_OPTIONS+=(-o IdentitiesOnly=yes -i "${BAAS_HOST_KEY}") -fi - -echo "running ssh with ${SSH_OPTIONS[*]}" -RETRY_COUNT=25 -WAIT_COUNTER=0 -WAIT_START=$(date -u +'%s') -CONNECT_COUNT=2 -TEST_COMMAND="[[ -f /data/baas-remote/baas-work-dir/baas_ready ]]" - -# Check for remote connectivity - try to connect twice to verify server is "really" ready -# The tests failed one time due to this ssh command passing, but the next scp command failed -while [[ ${CONNECT_COUNT} -gt 0 ]]; do - until ssh "${SSH_OPTIONS[@]}" -o ConnectTimeout=10 "${SSH_USER}" "${TEST_COMMAND}" ; do - if [[ ${WAIT_COUNTER} -ge ${RETRY_COUNT} ]] ; then - secs_spent_waiting=$(($(date -u +'%s') - WAIT_START)) - echo "Timed out after waiting ${secs_spent_waiting} seconds for host ${BAAS_HOST_NAME} to start" - exit 1 - fi - - ((++WAIT_COUNTER)) - printf "SSH connection attempt %d/%d failed. Retrying...\n" "${WAIT_COUNTER}" "${RETRY_COUNT}" - sleep 10 - done - - ((CONNECT_COUNT--)) -done - -echo "Detected remote baas server ready"