Files

Running API Tests in Kubernetes Cluster

Table of Contents

K8s Setup

Pre-requisites

  1. Install the following tools:

  2. Add these hosts to your /etc/hosts file:

    echo "127.0.0.1       ocis-server federation-ocis-server \
    clamav collabora onlyoffice fakeoffice tika \
    email" | sudo tee -a /etc/hosts
    

Deploy oCIS in K8s

  1. Change directory to <ocis-root>/tests/config/k8s:

    cd <ocis-root>/tests/config/k8s
    
  2. Create K8s Cluster

    make create-cluster
    
  3. Prepare Charts

    make prepare-charts
    

    Tip

    To run the test suites that require extra services, use the following appropriate environment variables:

    • ENABLE_ANTIVIRUS=true: Antivirus test suites
    • ENABLE_EMAIL=true: Notification test suites
    • ENABLE_TIKA=true: Content search test suites
    • ENABLE_WOPI=true: WOPI test suites
    • ENABLE_OCM=true: OCM test suites
    • ENABLE_AUTH_APP=true: auth-app test suites

    ⚠️ When using the above environment variables, make sure you run the necessary external services and expose them to the cluster. Check the respective test running sections for more details.

    Example:

    ENABLE_EMAIL=true make prepare-charts
    
  4. Deploy oCIS

    make deploy-ocis
    
  5. Check the ocis logs

    make show-logs
    

Running API Tests

Build and run the ociswrapper to be able to run the API tests tagged with @env-config.

  1. Change directory to the ocis root:

    cd <ocis-root>
    
  2. Build the ociswrapper:

    make -C tests/ociswrapper build
    
  3. Run the ociswrapper:

    tests/ociswrapper/bin/ociswrapper serve \
       --url https://ocis-server \
       --admin-username admin \
       --admin-password admin \
       --skip-ocis-run \
       -n ocis-server
    

Run General API tests

TEST_SERVER_URL=https://ocis-server \
K8S=true \
BEHAT_FEATURE=<test-suites-path>/apiDownloads/download.feature \
make test-acceptance-api

Run Notification API tests

  1. Check if setup step 3 is done correctly. (ENABLE_EMAIL=true)

  2. Start the email server

    docker run -d -p 1025:1025 -p 8025:8025 axllent/mailpit:v1.22.3
    
  3. Expose the email server to the cluster

    bash tests/config/k8s/expose-external-svc.sh email:1025
    
  4. Run the tests

    TEST_SERVER_URL=https://ocis-server \
    EMAIL_HOST=email \
    EMAIL_PORT=8025 \
    K8S=true \
    BEHAT_FEATURE=<test-suites-path>/apiNotification/notification.feature \
    make test-acceptance-api
    

Run Antivirus API tests

  1. Check if setup step 3 is done correctly. (ENABLE_ANTIVIRUS=true)

  2. Start the antivirus server

    docker run -d -p 3310:3310 owncloudci/clamavd
    
  3. Expose the antivirus server to the cluster

    bash tests/config/k8s/expose-external-svc.sh clamav:3310
    
  4. Run the tests

    TEST_SERVER_URL=https://ocis-server \
    K8S=true \
    BEHAT_FEATURE=<test-suites-path>/apiAntivirus/antivirus.feature \
    make test-acceptance-api
    

Run Full Text Search API tests

  1. Check if setup step 3 is done correctly. (ENABLE_TIKA=true)

  2. Start the tika server

    docker run -d -p 9998:9998 apache/tika:3.2.2.0-full
    
  3. Expose the tika server to the cluster

    bash tests/config/k8s/expose-external-svc.sh tika:9998
    
  4. Run the tests

    TEST_SERVER_URL=https://ocis-server \
    K8S=true \
    BEHAT_FEATURE=<test-suites-path>/apiSearchContent/contentSearch.feature \
    make test-acceptance-api
    

Run OCM tests

For running OCM test suite on k8s, we need to deploy a federation ocis server in a separate namespace on the same cluster, alongside the ocis server:

  1. Check if setup step 3 is done correctly. (ENABLE_OCM=true)

  2. Prepare Charts for federation oCIS

    OCM=true make prepare-charts
    
  3. Deploy federation oCIS

    OCM=true make deploy-ocis
    
  4. Run the tests

    TEST_SERVER_URL=https://ocis-server \
    TEST_SERVER_FED_URL=https://federation-ocis-server \
    K8S=true \
    BEHAT_FEATURE=<test-suites-path>/apiOcm/share.feature \
    make test-acceptance-api
    

Cleanup the Setup

To delete the cluster and all the setup resources, run the following command:

make -C <ocis-root>/tests/config/k8s cleanup

This will delete the K8s cluster, ocis-charts, and ocis logs directory.