Skip to content

Developers Guide

Guy Margalit edited this page Apr 2, 2020 · 8 revisions

Setting up a developer environment

Please refer to the following guides for setting up a developer environment
OSX
Linux

To start a local environment, after following the above guides, start by installing/updating your dependencies by running

npm install
npm run build

from the project root.
This will bring the new npm deps, will build the native code and will call the gulp build task for the frontend component.

Make sure mongod is running or run it manually by

npm run db

then start the system by running each of the components on its own (if you choose this way, preferably in different shells)

npm run web
npm run bg
npm run hosted_agents

sudo npm run s3

Note that the s3rver listens on port 80 and needs to be run with a privileged user

Project Directory Structure

Please refer to Directory Structure for better understanding of the project's directory structure

Building & Testing

Building

On your local env, you can build the various components in the following way:

  1. Building the BE services, from the project core dir (this will also build the Frontend component)

npm install
  1. Building the Frontend component, from the frontend dir

gulp build
  1. Building NooBaa operator

NooBaa operator is a Kubernetes controller that manages NooBaa resource in Kubernetes. There are 2 options to build and run NooBaa operator.

  • Build and run locally on your dev machine (for dev and debug purposes)

    You can build and run the operator locally without building and deploying a docker image. This is useful for testing changes during the development and debugging of the operator.
    • Before running locally, you first need to deploy NooBaa CRD and RBAC resources. Use This yaml file but first comment out the deployment document in the yaml (at the bottom of the file). From the project core dir run
    kubectl apply -f ./gocode/src/noobaa-operator/deploy/noobaa-operator.yaml
    
    • To build and run the operator run:
    ./src/deploy/build_operator.sh run
    
    This will build and run the operator on your machine, but the controller will handle NooBaa CRD on the Kubernetes cluster which is configured in your current context (kubectl config current-context)
  • Build a docker image to deploy as a kubernetes deployment

    • To build a docker image of NooBaa operator run
    ./src/deploy/build_operator.sh
    
    you can also build and push with:
    ./src/deploy/build_operator.sh push TARGET_IMAGE[:TAG]
    
    kubectl apply -f ./gocode/src/noobaa-operator/deploy/noobaa-operator.yaml
    

Testing

The tests in the project are divided into four categories:

Unit tests

These are tests which can ran at any location which satisfies the developer environment requirements. They do not require a NooBaa installation to run on.
NooBaa is using mocha as its unit test framework and they are located in src/tests/unit_tests

Running unit tests on your code is as easy as running

npm test

You can also run a single test by providing its name, for example

mocha src/test/unit_tests/test_semaphore.js

would run the test_semaphore unit test

System Tests

These are tests which involve several components or end ot end flows in the system. They require a running NooBaa system (can be a local dev system) to run on.
They are located in src/tests/system_tests and can be run one after the other using the src/test/framework/runner component
For example, running

Nightly Pipeline

These are tests which ran on more complex environments, combine several flows in the system and run at higher capacities than system tests.
They are being run each night on the latest successful build by the CI orchestration (Jenkins). They are located at src/test/qa

Test Utils

The tests sometimes require specific utils (manipulating agents or server status, creating certain bucket policies etc.) These utils can be found at src/test/utils

Clone this wiki locally