Challenge Overview
Project Overview
TopCoder and the TopCoder community have worked hard to get the platform to its currently level of maturity, but we're far from done. It's time to take the platform to the next level. TopCoder is going to start taking some steps to open up the platform API to the outside and community developers so they could incorporate it in their websites, applications or build their own applications (web, mobile or desktop).
The ultimate goal is to open up and build an "API" that is targeting all different type of audiences - Software and Studio Competitors, SRM/MM competitors, Copilots, Admins and TopCoder partners - each audience will have different interests and usages of the API, so it will be a huge project and we need to make sure that we are in the right direction from the beginning.
Currently, we have run several contests to build the APIs and write tests for testing the APIs. All the tests can be found at https://github.com/cloudspokes/tc-api/tree/master/test
Through these contests, we have found several problems for the tests part as following
- The tests are not properly named, we'd like to follow the way like 'test.[api name].js', like register_member.js should be renamed to test.register_member.js.
- Some of the tests have to presetup the database manually, Some of the tests automically setup and clear the related database tables wisely.
- The tests can be passed if run separately, but failed when running togather.
For this contest, we'd like to improve and standarize the way to write tests, so it will be good for further addon and CI integration.
Competition Task Overview
Please raise questions as quick as you can, I am familiar with related database and code base, I can provide as much support as I can.
The updated code must still deploy and work on heroku - any submission which can't be deployed on heroku successfully will be failed in screening phase - primary reviewer must check this.
The implementation will base on the node.js version of TC platform API - https://github.com/cloudspokes/tc-api. Please follow the existing actionhero pattern for your development.
Clean State for Running Tests
Currently, some tests requires presetup the database, some tests automically setup and clear the related database tables.
We'd like to follow the approach to setup and clear the related database tables before and after running the tests.
Currently, register_member.js used similar approach to setup the data before running tests. We'd like to extra similar logic as utility methods, which can be used to execute a batch of sqls (for example, inside one file) or single sql against one database (Currently we can not do with multiple databases, due to the limitation of nodejs informix module).
With this utility methods we can easily do setup and teardown databases.
before, after, before each, after each hooks
Utilize before()
, after()
, beforeEach()
, afterEach()
to setup the tests more wise. For detail information, please check http://visionmedia.github.io/mocha/
Test Directory Restructure and Normalization
We'd like to normalize the directory structure inside test directory. Currently, it already gives good starting point, but we'd like revise it as we are making the above changes. Here is the general rules to following
- All tests should be named like test.[api name].js, so normally, for each api, there should be separated test js files.
- All tests from contest winner, should be put directly under test directory.
- All reviewers tests should be put under corresponding directory under test directory, like accuracy, failure, security directory.
- All sql files used for tests presetup and teardown should be put under sqls directory, sqls files for accuray, failture, security tests, will be in different directory, directly under the accuracy, failure, security directory, like accuracy/sqls, failure/sqls etc.
- All other test related files will be still put under test_files directory.
If you have better idea and improvement to make the test directory well orginized, please suggest. This can be considered as improvement, reviewers and PMs will consider that.
Scope
All tests under test directory are in scope. If it tests didn't pass orignally, you should be responsible to fix that.
The ultimate goal is we can run all tests or single test successfully. like
Run a single test: ./node_modules/.bin/mocha ./test/test.tops.js
Run all tests: ./node_modules/.bin/mocha ./test
Following steps to run the tests.
- setup environment varibales: . deploy/development.sh
- start the local server: npm start
- run the tests: as above commands.
Tests Creation Guide
Beside the above requirements for current tests normalization and improvement, we'd like you to write a general guide which can be followed to further test creation. It just need to be easy to follow.
Testing
The API Framework supports tests. Use supertest with mocha. Don't install mocha globally.
you must use mocha BDD style (which is the default), within that, you can optionally use chai.
Code Format
All code must pass jslint. You may use "nomen: true".
Winner Only
Winner will create pull request against the main github repo in final fix phase and merge the code.
Virutal Machines (VMs)
VM specific information is found here: http://www.topcoder.com/wiki/display/docs/VM+Image+2.5
Upon registration as a submitter or reviewer you will need to request a VM based on the TopCoder systems image. The VM will be active through aggregation review, after which it will be terminated except for the winner's and the reviewers'. To request your image, please post in contest forum.
Before requesting your VM, you need to ensure that you have an SSH key created and in your member profile. Instructions to do so are here: http://www.topcoder.com/wiki/display/projects/Generate+SSH+Key, and instructions to connect afterwards are here: http://www.topcoder.com/wiki/display/projects/Connect+Using+SSH+Key.
Please realize that VMs are currently issued manually. We make every attempt to issue the VM as soon as it is requested, however, there may be delays of up to 12 hours depending on time of day when you request. We encourage everyone to request a VM as soon as possible to minimize any such delays.
Technology Overview
- JavaScript
- Node.js 0.10.x
- actionhero.js framework
- supertest
- mocha
Documentation Provided
Please check the deployment guide in codebase for reference.
Final Submission Guidelines
Submission Deliverables
A complete list of deliverables can be viewed in the TopCoder Assembly competition Tutorial at: http://apps.topcoder.com/wiki/display/tc/Assembly+Competition+Tutorials
Below is an overview of the deliverables:
- Source Code.
- Deployment guide to configure and verify the application.
- General Test Creation Guide
Final Submission
For each member, the final submission should be uploaded to the Online Review Tool.