Home > Enterprise >  Spinning Up a Staging Server for Testing a Django Web-Application
Spinning Up a Staging Server for Testing a Django Web-Application

Time:04-05

I have been following Harry J.W. Percival's Test-Driven Development with Python. In the chapter of "Testing Deployment Using a Staging Site", I am confused as to the course of action that I should take now to implement this:

Spinning Up a Server

I’m not going to dictate how you do this—whether you choose Amazon AWS, Rack‐space, Digital Ocean, your own server in your own data centre or a Raspberry Pi in a cupboard behind the stairs, any solution should be fine, as long as:

  • Your server is running Ubuntu (13.04 or later).

  • You have root access to it.

  • It’s on the public Internet.

  • You can SSH into it.

I am a beginner with respect to the framework. Hence, the topic of Deployment and Staging is somewhat unnerving for me, owing to my inexperience. The author previously states that we may either run our own (possibly virtual) server or go for PaaS.

So, my query is how do I accomplish the process of setting up a staging server for verification and validation testing purposes (links to sources explaining the process shall be greatly acknowledged)?

Given the nature of my problem, I could not figure out how to move ahead. Should I use a Virtual Machine to move forward? Or... well, what exactly should I do? I'm pretty much out of ideas here.

A half-baked potential solution that I had cooked up was creating a Heroku pipeline that has three phases (development, staging and production). Given the fact that a Staging server should be similar to the Production server, I had hoped to make one app in the pipeline that gradually moves over to the final stage. But this seems to be counterintuitive with respect to Test-Driven Development since development and testing should go hand-in-hand (not to mention that the book I am following chooses server-admin over PaaS).

(This is my first question here and I hope I could make myself clear without offending anyone or wasting their time)

CodePudding user response:

First of all I would stay with Heroku, they do an awesome job with their pipelines and so on and you want to focus on your development and not server maintance.

Second, for local testing only you can just use the runserver command. If it works, move the current state to the staging. After verifying there, you can move it to production.

If you mean by testing automated ci testing, you can use heroku there or github actions (when you are using github). The flow would be -> local test (manual and automated) -> automated ci test (optional) -> automated deploy to staging -> you can check your application here in the same env as your production env -> deploy to production

CodePudding user response:

You can provision and compute machine in any cloud providers (AWS, GCP, Azure, DigitalOcean, PythonAnywhere, the list goes on). However, given that you are in the initial stage of learning the framework, I suggest you go on installing ubuntu as a virtual machine in your own computer. You can setup 3 vms, each for dev, stage, and production.

My suggestion will be the following:

  1. Install virtualbox
  2. Setup ubuntu server in virtualbox
  3. Setup domain name to point to the appropriate vm's ip
  4. Connect to vm using ssh

Some resources you may find helpful:

  • Related