Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 522209 - Port the CF tests
  • Loading branch information
mrennie committed Sep 18, 2017
1 parent 56995a3 commit 3c74d4d
Show file tree
Hide file tree
Showing 25 changed files with 1,124 additions and 3 deletions.
803 changes: 803 additions & 0 deletions modules/orionode/test/endpoints/test-cfapi.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion modules/orionode/test/endpoints/test-workspace.js
Expand Up @@ -66,7 +66,7 @@ describe("Workspace endpoint", function() {
}, false);
});
afterEach("Remove .test_workspace", function(done) {
testData.tearDown(testHelper.WORKSPACE, function(){
testData.tearDown(WORKSPACE, function(){
testData.tearDown(path.join(MEATASTORE, '.orion'), function(){
testData.tearDown(MEATASTORE, done);
})
Expand Down
9 changes: 7 additions & 2 deletions modules/orionode/test/support/testHelper.js
Expand Up @@ -22,6 +22,11 @@ exports.CONTEXT_PATH = CONTEXT_PATH = '';
* @since 16.0
*/
exports.WORKSPACE = WORKSPACE = path.join(__dirname, '.test_workspace');
/**
* The absolute path to the test metadata. Default value is __dirname + .test_metadata
* @since 16.0
*/
exports.WORKSPACE = WORKSPACE = path.join(__dirname, '.test_metadata');
/**
* The id of the test workspace. Value is orionode
* @since 16.0
Expand All @@ -33,10 +38,10 @@ exports.WORKSPACE_ID = WORKSPACE_ID = "anonymous-OrionContent";
*/
exports.FILE_PATH = FILE_PATH = CONTEXT_PATH + '/file';
/**
* The complete file enpoint prefix. Default value is FILE_PATH + / + WORKSPACE_ID
* The path to the workspace endpoint
* @since 16.0
*/
exports.PREFIX = PREFIX = FILE_PATH + '/' + WORKSPACE_ID;
exports.WORKSPACE_PATH = WORKSPACE_PATH = CONTEXT_PATH + '/workspace';

/**
* @name createDir
Expand Down
39 changes: 39 additions & 0 deletions modules/orionode/test/support/test_data.js
Expand Up @@ -112,4 +112,43 @@ exports.setUp = function setUp(dir, callback, wsjson) {
}
}

exports.setUpCF = function setUpCF(dir, callback) {
function createFiles() {
//copy in all the files
var test_data_path = path.join(__dirname, "../testData/manifestTest");
var files = fs.readdirSync(test_data_path);
if(Array.isArray(files)) {
files.forEach(function(file) {
if(!fs.statSync(path.join(test_data_path, file)).isFile()) {
return;
}
var rs = fs.createReadStream(path.join(test_data_path, file)),
ws = fs.createWriteStream(path.join(cf, file));
rs.on('error', (err) => {
console.log(err.message)
});
ws.on('error', (err) => {
console.log("error writing to: "+err.message)
});
rs.pipe(ws);
});
}
callback();
}
var cf = path.join(dir, "cftests");
if(fs.existsSync(cf)) {
debug('\nDirectory exists; cleaning...');
tearDown(cf, function(err) {
if (err) {
debug(err);
return;
}
fs.mkdirSync(cf);
createFiles();
});
} else {
fs.mkdirSync(cf);
createFiles();
}
}
exports.DEBUG = process.env.DEBUG_TESTS || false;
16 changes: 16 additions & 0 deletions modules/orionode/test/testData/manifestTest/appCustomConfig.yml
@@ -0,0 +1,16 @@
---
path: .
domain: example.com
memory: 256M
instances: 1
services:
- singular-backend

# app-specific configuration
applications:
- name: springtock
host: 765shower
path: ./april/build/libs/april-weather.war
- name: wintertick
subdomain: 321flurry
path: ./december/target/december-weather.war
16 changes: 16 additions & 0 deletions modules/orionode/test/testData/manifestTest/appsNestedServices.yml
@@ -0,0 +1,16 @@
applications:
- name: mysample
memory: 256M
instances: 1
host: tapp
domain: ctapps.io
path: .
services:
rediscloud-8cccc:
type: rediscloud
provider: garantiadata
plan: 20mb
mongolab-6d208:
type: mongolab
provider: mongolab
plan: sandbox
10 changes: 10 additions & 0 deletions modules/orionode/test/testData/manifestTest/argReplace.yml
@@ -0,0 +1,10 @@
---
applications:
- name: orionode
memory: 128M
instances: 1
path: .
url: orionode${random-word}.${target-base}
runtime: node08
command: node server.js
framework: node
4 changes: 4 additions & 0 deletions modules/orionode/test/testData/manifestTest/badIndent.yml
@@ -0,0 +1,4 @@
---
applications:
- name: myTestApp
someProperty: testValue
@@ -0,0 +1,2 @@
applications:
: asd -
32 changes: 32 additions & 0 deletions modules/orionode/test/testData/manifestTest/complexEnvAndApps.yml
@@ -0,0 +1,32 @@
---
properties:
app-host: ${name}

path: .
env:
RAILS_ENV: ${rails-env}
RACK_ENV: ${rails-env}
BUNDLE_WITHOUT: test:development
services:
frontend-db:
type: cleardb
provider: cleardb
plan: shock
mem: 512M
disk: 1G
instances: 1
host: none
domain: none

# app-specific configuration
applications:
- name: frontend
host: ${app-host}
domain: ${target-base}
instances: 2
command: bundle exec rake server:start_command
- name: app2-worker1
instances: 2
command: bundle exec rake VERBOSE=true QUEUE=*
- name: app2-worker2
command: bundle exec rake VERBOSE=true
13 changes: 13 additions & 0 deletions modules/orionode/test/testData/manifestTest/globalAndInherit.yml
@@ -0,0 +1,13 @@
---
inherit: simple-base-manifest.yml
applications:
- name: springstorm
memory: 512M
instances: 1
host: 765deluge
path: ./april/build/libs/april-weather.war
- name: winterblast
memory: 1G
instances: 2
host: 321blizzard
path: ./december/target/december-weather.war
@@ -0,0 +1,18 @@
---
inherit: base-manifest.yml

properties:
rails-env: production
app-host: app1-host

applications:
- name: app1-web
host: ${app-host}
domain: ${target-base}
instances: 8
command: bundle exec rake server:start_command
- name: app1-worker1
instances: 4
command: bundle exec rake VERBOSE=true QUEUE=*
- name: app1-worker2
command: bundle exec rake VERBOSE=true
6 changes: 6 additions & 0 deletions modules/orionode/test/testData/manifestTest/longCommand.yml
@@ -0,0 +1,6 @@
---
applications:
- name: quotetest
memory: 512M
command: node_modules/.bin/foo --foo "bar" --baz "" -- fizz buzz
test: hi
@@ -0,0 +1,2 @@
applications:
- : asd
@@ -0,0 +1,2 @@
applications:
- name: :
@@ -0,0 +1,24 @@
applications:
- name: publisher
memory: 64M
path: ./publisher
domain: cfapps.io
host: publisher
instances: 1
services:
work-queue:
type: rediscloud
provider: garantiadata
plan: 20mb
depends-on: ./subscriber
- name: subscriber
memory: 64M
path: ./subscriber
domain: cfapps.io
host: subscriber
instances: 1
services:
work-queue:
type: rediscloud
provider: garantiadata
plan: 20mb
@@ -0,0 +1,21 @@
---
applications: #Reference http://docs.cloudfoundry.com/docs/using/deploying-apps/manifest.html
- name: TwitterSearchAnalyzerNode #Application Name. Unique to the user's Space
memory: 256M #The maximum memory to allocate to each application instance
instances: 1 #The number of instances of the application to start
url: TwitterSearchAnalyzerNode${random-word}.${target-base} #deprecated, kept for temporary compatibility
host: TwitterSearchAnalyzerNode-${random-word} #Hostname for app routing. Unique to domain
domain: ${target-base} #Bluemix Parent Domain Name
path: . #Path to the application to be pushed
command: node app.js #The command to use to start the application
services:
ctas-tsa-node: #Identifier for CompaniesTextAnalyticsService Bound Service instance
label: CompaniesTextAnalyticsService
provider: jStart
version: '0.1'
plan: 'free'
ntas-tsa-node: #Identifier for NamesTextAnalyticsService Bound Service instance
label: NamesTextAnalyticsService
provider: jStart
version: '0.1'
plan: 'free'
@@ -0,0 +1,23 @@
---
# this manifest deploys two applications
# apps are in flame and spark directories
# flame and spark are in fireplace
# cf push should be run from fireplace
applications:
- name: spark
memory: 1G
buildpack: http://example.com#something
instances: 2
host: flint-99
domain: example.com
path: ./spark/
services:
- mysql-flint-99
- name: flame
memory: 1G
instances: 2
host: burnin-77
domain: example.com
path: ./flame/
services:
- redis-burnin-77
@@ -0,0 +1,13 @@
applications:
- name: spock
memory: 1G
instances: 1
services:
- volcan
- uss-enterprise
- name: kirk
memory: 1G
instances: 1
services:
- earth
- spock
@@ -0,0 +1,9 @@
---
applications:
- name: quoted-path-application
memory: 64M
instances: 1
path: "."
host: 'quoted-path-application'
domain: cloud-foundry-domain.org
command: node app.js
11 changes: 11 additions & 0 deletions modules/orionode/test/testData/manifestTest/servicesWithSpaces.yml
@@ -0,0 +1,11 @@
---
applications:
- name: cf-node-mb-TEST
host: cf-node-mb-TEST3
command: node server.js
path: .
instances: 1
memory: 256MB
services:
- Redis Cloud-fo service
- Redis-two
7 changes: 7 additions & 0 deletions modules/orionode/test/testData/manifestTest/simpleGlobal.yml
@@ -0,0 +1,7 @@
applications:
- name: nodetestdh01
memory: 64M
instances: 2
host: crn
domain: csapps.io
path: .
14 changes: 14 additions & 0 deletions modules/orionode/test/testData/manifestTest/simpleGlobalProps.yml
@@ -0,0 +1,14 @@
---
# all applications use these settings and services
domain: example.com
memory: 1G
instances: 1
services:
- clockwork-mysql
applications:
- name: springtock
host: tock09876
path: ./spring-music/build/libs/spring-music.war
- name: springtick
subdomain: tick09875
path: ./spring-music/build/libs/spring-music.war
22 changes: 22 additions & 0 deletions modules/orionode/test/testData/manifestTest/simpleTwoApps.yml
@@ -0,0 +1,22 @@
---
# this manifest deploys two applications
# apps are in flame and spark directories
# flame and spark are in fireplace
# cf push should be run from fireplace
applications:
- name: spark
memory: 1G
instances: 2
host: flint-99
domain: example.com
path: ./spark/
services:
- mysql-flint-99
- name: flame
memory: 1G
instances: 2
host: burnin-77
domain: example.com
path: ./flame/
services:
- redis-burnin-77
@@ -0,0 +1,9 @@
---
applications:
- name: TargetBaseExampleApp
memory: 256M
instances: 1
url: App-${random-word}.${target-base}
host: App-${random-word}
domain: ${target-base}
path: .

0 comments on commit 3c74d4d

Please sign in to comment.