启动临时服务器来测试 Django Web 应用程序

发布于 2025-01-18 20:49:20 字数 871 浏览 2 评论 0 原文

我一直在关注 Harry JW Percival 的Python 测试驱动开发。在“使用临时站点测试部署”一章中,我对现在应该采取的行动过程感到困惑来实现这一点:

启动服务器

我不会规定您如何做到这一点 - 无论您选择 Amazon AWS、Rack‐space、Digital Ocean、您自己的数据中心中的自己的服务器还是楼梯后面橱柜中的 Raspberry Pi,任何解决方案都应该没问题,只要:

  • 您的服务器正在运行 Ubuntu(13.04 或更高版本)。

  • 您拥有其 root 访问权限。

  • 它位于公共互联网上。

  • 您可以通过 SSH 连接到它。

我是该框架的初学者。因此,由于我缺乏经验,部署和分期这个话题对我来说有点令人不安。作者之前指出,我们可以运行自己的(可能是虚拟的)服务器,也可以选择 PaaS。

因此,我的问题是如何完成设置临时服务器以进行验证和确认测试的过程(应大力感谢解释该过程的来源链接)?

鉴于我的问题的性质,我不知道如何继续前进。我应该使用虚拟机继续前进吗?或者……好吧,我到底应该做什么?我在这里几乎没有想法。

我制定的一个半成品的潜在解决方案是创建一个具有三个阶段(开发、登台和生产)的 Heroku 管道。考虑到登台服务器应该与生产服务器类似,我希望在管道中制作一个逐渐进入最后阶段的应用程序。但这对于测试驱动开发来说似乎是违反直觉的,因为开发和测试应该齐头并进(更不用说我正在关注的书选择服务器管理而不是 PaaS)。

(这是我的第一个问题,我希望我能说清楚,不要冒犯任何人或浪费他们的时间)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

装纯掩盖桑 2025-01-25 20:49:21

您可以在任何云提供商(AWS,GCP,Azure,Digitalocean,Pythonanywhere)中提供和计算机器。但是,鉴于您处于学习框架的初始阶段,我建议您继续在自己的计算机中安装Ubuntu作为虚拟机。您可以设置3个VM,每个VM用于开发,舞台和生产。

我的建议将为以下内容:

  1. 在VirtualBox设置域名中安装VirtualBox
  2. 设置Ubuntu Server,
  3. 以指向适当的VM的IP
  4. 连接到VM,使用SSH

一些资源您可能会发现有用:

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:

沫离伤花 2025-01-25 20:49:21

首先,我会留在 Heroku,他们在管道等方面做得非常出色,你想专注于你的开发而不是服务器维护。

其次,仅对于本地测试,您可以使用 runserver 命令。如果有效,请将当前状态移至暂存。在那里验证后,您可以将其转移到生产中。

如果您的意思是测试自动化 ci 测试,您可以使用 heroku 或 github actions(当您使用 github 时)。流程将是 ->本地测试(手动和自动)->自动化 ci 测试(可选)->自动部署到暂存 ->您可以在与生产环境相同的环境中检查您的应用程序 ->部署到生产

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文