为外部开发人员设置测试环境

时间:2018-06-19 07:32:52

标签: docker continuous-integration automated-tests sandbox

背景信息:为外部程序开发人员设置短信环境,以便以后集成到自己的平台中。

我是否知道沙盒和开发服务器用于测试的主要区别是什么?

如果假设您为您的应用程序使用java,jsp,html,css,js,mysql,但您也在使用外部开发人员使用相同的语言和db进行开发,后者将被集成到同一语言中平台作为当前现有的其他应用。

所以问题是沙箱主要用于将应用程序与其他环境分离,因此如果项目中有文件系统上的文件,沙箱需要分开,文件系统,数据库。沙箱和开发服务器可能会有文件系统允许外部开发人员访问它。那么这会给我们留下码头选项吗?但是如果我们说整个应用程序是在docker上完成的,那么它可以链接到实时服务器吗?

还有怎样的CI / CD管道呢?鉴于所选的选项,我们如何测试? 您认为哪种方案最合适?

1 个答案:

答案 0 :(得分:0)

Vagrant

怎么样?

对于单独的开发环境来说,它是非常好的工具。共享存储可以用于您需要的一切 - 数据库,文件系统。每台机器的本地网络是分开的。所有环境配置都在一个文件(example Vagrantfile)中进行,因此只为新开发人员设置:

import urllib.request
urllib.request.urlretrieve('https://i.stack.imgur.com/UBIuA.jpg', 'm3.jpg')


import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
from scipy import ndimage
import cartopy.feature

im = plt.imread('m3.jpg')
im = im[:,85:995] # crop only the first part of whole image

rot = 198.3913296679117 # degrees, direction of sat movement
center = (50.83550180700588, 16.430852851867176) # lat long

import numpy as np
from cartopy.geodesic import Geodesic
import matplotlib.transforms as mtransforms
from matplotlib.axes import Axes


tweaked_rot = rot - 3.2

geod = Geodesic()
# Move the center along the trajectory of the satellite by 10KM
f = np.array(
        geod.direct([center[1], center[0]],
                    180 - tweaked_rot,
                    10000))

tweaked_center = f[0, 0], f[0, 1]

# Move the satellite perpendicular from its proposed trajectory by 15KM
f = np.array(
        geod.direct([tweaked_center[0], tweaked_center[1]],
                    180 - tweaked_rot + 90,
                    10000))
tweaked_center = f[0, 0], f[0, 1]


data_crs = ccrs.NearsidePerspective(
    central_latitude=tweaked_center[1],
    central_longitude=tweaked_center[0],
)

# Compute the center in data_crs coordinates.
center_lon_lat_ortho = data_crs.transform_point(
    tweaked_center[0], tweaked_center[1], ccrs.Geodetic())

# Define the affine rotation in terms of matplotlib transforms.
rotation = mtransforms.Affine2D().rotate_deg_around(
    center_lon_lat_ortho[0], center_lon_lat_ortho[1], tweaked_rot)

# Some fudge factors. Sorry - there are entirely application specific,
# perhaps some reading of https://www.cder.dz/download/Art7-1_1.pdf
# would enlighten these... :(
ff_x, ff_y = 0.62, 0.65
ff_x = ff_y = 0.81
x_extent = im.shape[1]*4000/2 * ff_x
y_extent = im.shape[0]*4000/2 * ff_y
img_extent = [-x_extent, x_extent, -y_extent, y_extent]


fig = plt.figure(figsize=(10, 10))
ax = plt.axes(projection=data_crs)
ax.margins(0.02)
with ax.hold_limits():
    ax.stock_img()


# Uing matplotlib's image transforms if the projection is the
# same as the map, otherwise we need to fall back to cartopy's
# (slower) image resampling algorithm
if ax.projection == data_crs:
    transform = rotation + ax.transData
else:
    transform = rotation + data_crs._as_mpl_transform(ax)


# Use the original Axes method rather than cartopy's GeoAxes.imshow.
mimg = Axes.imshow(ax, im, origin='upper', cmap='gray',
                   extent=img_extent, transform=transform)


lower_left = rotation.frozen().transform_point([-x_extent, -y_extent])
lower_right = rotation.frozen().transform_point([x_extent, -y_extent])
upper_left = rotation.frozen().transform_point([-x_extent, y_extent])
upper_right = rotation.frozen().transform_point([x_extent, y_extent])

plt.plot(lower_left[0], lower_left[1],
         upper_left[0], upper_left[1],
         upper_right[0], upper_right[1],
         lower_right[0], lower_right[1],
         marker='x', color='black',
         transform=data_crs)

ax.coastlines(resolution='10m', color='yellow', linewidth=1)
ax.add_feature(cartopy.feature.BORDERS, linestyle='-', edgecolor='yellow')


sat_pos = np.array(geod.direct(tweaked_center, 180 - tweaked_rot,
                               np.linspace(-x_extent*2, x_extent*2, 50)))

with ax.hold_limits():
    plt.plot(sat_pos[:, 0], sat_pos[:, 1], transform=ccrs.Geodetic(),
             label='Satellite path')
plt.plot(tweaked_center, 'ob')
plt.legend()

当然,你可以使用像Ansible或Puppet这样的CM工具来安装像webserver,DB server这样的安装软件,并像创建用户,dirs那样进行操作系统更改。保持所有开发环境处于相同状态的简单方法。如果出现意外的开发人员错误,例如破坏某些配置,或mkdir dev2 && cd dev2 && cp dev1/Vagrantfile . && vagrant up 它只会重新创建需要几分钟的机器。 关于CI / CD测试,我喜欢简单的解决方案。在詹金斯管道

rm -rf /home/*

Fie checkout scm: [$class: 'GitSCM', userRemoteConfigs: [[url: repoWithTests]], branches: [[name: 'master']]], poll: false sh(script: "python tests.py", returnStdout: true) 它是带有unittest.TestCase的简单脚本,用于检查enpoints,grep日志以及它可能需要的任何内容。

总结在我看来,Vagrant是比船坞人更好的模拟真机的方法。 Docker最适合单独的一个应用程序,而不是整个机器。