我正在开发一个更大的软件的快照并构建快照,删除旧的,安装新的只需要很长时间。
我想迭代创建快照并更快地进行测试。我知道 snap 构建得很好,现在我有兴趣测试诸如启动应用程序及其集成之类的事情。有没有办法做到这一点?
解决此问题的一种方法是使用snap try. 从它的--help消息:
The try command installs an unpacked snap into the system for testing
purposes. The unpacked snap content continues to be used even after
installation, so non-metadata changes there go live instantly. Metadata
changes such as those performed in snap.yaml will require reinstallation
to go live.
Run Code Online (Sandbox Code Playgroud)
它还带有一个选项:
--devmode Install in development mode and disable confinement
Run Code Online (Sandbox Code Playgroud)
如果您想测试限制位并正确使用接口,这将特别有用。
使用方法很简单,直接运行:
snapcraft prime
snap try prime/
Run Code Online (Sandbox Code Playgroud)
在第一步你告诉snapcraft做
Final copy and preparation for the snap.
Run Code Online (Sandbox Code Playgroud)
在第二步中snapd,使用目录的内容来“安装” snap。现在,您可以使用该包,同时仍然可以对其进行更改。
让我们使用Snappy Playpen 中的一个示例来展示如何使用它。
我们正在使用 consul,因为它的构建和使用速度相对较快:
$ git clone https://github.com/ubuntu/snappy-playpen
$ cd snappy-playpen/consul/
snappy-playpen/consul$ snapcraft prime
Preparing to pull consul
[...]
Staging consul
Priming consul
snappy-playpen/consul$
Run Code Online (Sandbox Code Playgroud)
现在让我们确保我们没有安装它的另一个版本,然后继续安装。
snappy-playpen/consul$ which consul
snappy-playpen/consul$ snap try prime
Name Version Rev Developer Notes
consul 0.6.4 x1 try
snappy-playpen/consul$ consul --help
usage: consul [--version] [--help] <command> [<args>]
Available commands are:
agent Runs a Consul agent
[...]
snappy-playpen/consul$
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好。它似乎工作得很好。现在让我们将其替换为/bin/echojust 看看事情是如何工作的:
snappy-playpen/consul$ cp /bin/echo prime/bin/consul
snappy-playpen/consul$ consul --help
Usage: /snap/consul/x1/bin/consul [SHORT-OPTION]... [STRING]...
or: /snap/consul/x1/bin/consul LONG-OPTION
Echo the STRING(s) to standard output.
[...]
daniel@daydream:/tmp/test/snappy-playpen/consul$
Run Code Online (Sandbox Code Playgroud)
如您所见,我们可以对实时系统进行更改,prime同时仍然在限制条件下运行。这通常是快速启动和运行并进行全面测试的好方法。
注:随着snapd2.0.10(2016年7月9日)之前,你必须运行之前temove卡snapcraft clean或snapd将进入一个糟糕的状态,并抱怨自己无法找到安装卡扣。2.0.11 中还有一些修复程序,它也应该会在几天内发布。
| 归档时间: |
|
| 查看次数: |
721 次 |
| 最近记录: |