# Orchard Simple Workflow Integration Tests

Simple Ruby tests to validate end to end feed ingestion.

## Installation

#### ODBC driver for Snowflake
1. Install unixodbc (brew install unixodbc / or use your apt-get, yum, etc.)
2. Download and install [ODBC driver for Snowflake](https://docs.snowflake.net/manuals/user-guide/odbc.html).
3. Adjust `odbc.ini` file, which will be placed to some system folder, like `/usr/local/Cellar/unixodbc/2.3.4/etc/odbc.ini` on Mac to contain the following lines (please adjust them accordingly to your settings and Snowflake role/schema/database which you'll be using to run integration tests):
```ini
[Data Sources]
testodbc = Snowflake
 
[testodbc]
Driver      = /opt/snowflake/snowflakeodbc/lib/universal/libSnowflake.dylib
Description = Snowflake ODBC
uid         = buvarov
server      = orchard.snowflakecomputing.com
role        = DEV_ENGINEERING
database    = DEV_ENGINEERING
schema      = BUVAROV
warehouse   = DEV_OWS_WAREHOUSE
```
We use `FACTS` db, `QA` schema and `QA_FEED_INGESTION_ROLE` to run integration tests from pull request Jenkins job. 

#### Ruby environment
Ensure `rvm` is installed. If it is not

```
\curl -sSL https://get.rvm.io | bash -s stable
```

 Then run:

```
rvm install 2.4.1
```

#### Create Envfile
In swf-feed-ingestion/integration_tests directory, copy Envfile.example to Envfile and populate configuration variables

```
cp Envfile.example Envfile
```

- set the value of `WORKFLOW_DOMAIN` to the same value as `Environment` in your
root dir `.env` file

#### Bundle install
In swf-feed-ingestion/integration_tests directory, run the following to install all required ruby gems.

```
cd integration_tests
bundle install
```

#### Verify environment variables
Have you sourced `.env` from the repo root directory?

#### Install sshpass (on Mac OS)
We use `sshpass` to provide the ability to use ftp semantics with our sftp
server when testing uploading/downloading files.

You can download sshpass for Mac here:
[https://sourceforge.net/projects/sshpass/files/sshpass/1.04/sshpass-1.04.tar.gz/download]

Once downloaded and untar'ed, follow the instructions in INSTALL.  You may need
to run the last `make install` step with `sudo`.

#### Run the tests
To run all specs, in swf-feed-ingestion/integration_tests directory, you can do:

```
rspec spec/
```

By default RSpec will recursively find all files named `*_spec.rb` and execute
all contained specs.

#### Quick RSpec Guide

- Execute All specs (under a directory)

  `rspec specs/`

- List All specs (under a directory)

  `rspec --dry-run specs/`

- Execute just one spec file

  `rspec path_to_file_spec.rb`

- Execute all specs in a file (or directory) with description containing a string

  `rspec path_to_file_spec.rb --example 'this will run any specs containing this message in their desription'`
