def setUp(self): self.host = "test-cd-host-" + commons.gen_random_num() self.envName = "test-cd-env-" + commons.gen_random_num() self.env_canary = commons.create_env(self.envName, CANARY) self.env_prod = commons.create_env(self.envName, PROD) self.commit = commons.gen_random_num(32) self.build = commons.publish_build(self.envName, commit=self.commit)
def setUp(self): self.envName = "ping-test-env-" + commons.gen_random_num() self.commit = commons.gen_random_num(32) self.host = "ping-test-host-" + commons.gen_random_num() self.group = "ping-test-group-" + commons.gen_random_num() self.groups = [self.group] self.env = commons.create_env(self.envName, stageName) environs_helper.update_env_capacity(commons.REQUEST, self.envName, stageName, data=self.groups) environs_helper.update_env_basic_config(commons.REQUEST, self.envName, stageName, {"maxParallel": 5}) environs_helper.update_env_script_config(commons.REQUEST, self.envName, stageName, {"s-c-n": "s-c-v"}) environs_helper.update_env_agent_config(commons.REQUEST, self.envName, stageName, {"a-c-n": "a-c-v"}) self.build = commons.publish_build("ping-test", "master", commit=self.commit) self.deploy = deploys_helper.deploy(commons.REQUEST, self.envName, stageName, self.build['id'])
def setUpClass(cls): cls.envName = "test-config-" + commons.gen_random_num() cls.stageName = "prod" data = {} data["description"] = "foo's \"big deal\"." data["envName"] = cls.envName data["stageName"] = cls.stageName environs_helper.create_env(commons.REQUEST, data)
def setUpClass(cls): cls.envName = "test-deploy-" + commons.gen_random_num() data = {} data["envName"] = cls.envName data["stageName"] = CANARY data["acceptanceType"] = "MANUAL" cls.canaryEnvId = environs_helper.create_env(commons.REQUEST, data)["id"] data = {} data["envName"] = cls.envName data["stageName"] = PROD cls.prodEnvId = environs_helper.create_env(commons.REQUEST, data)["id"] cls.buildId1 = commons.publish_build(cls.envName)['id'] cls.buildId2 = commons.publish_build(cls.envName)['id']
def testFailPolicyROLLBACK(self): commit_0 = commons.gen_random_num(32) build_0 = commons.publish_build(self.envName, commit=commit_0) deploy_0 = deploys_helper.deploy(commons.REQUEST, self.envName, PROD, build_0['id']) deploys_helper.update_progress(commons.REQUEST, self.envName, PROD) environs_helper.update_env_capacity(commons.REQUEST, self.envName, PROD, capacity_type="HOST", data=[self.host]) deploy = deploys_helper.deploy(commons.REQUEST, self.envName, PROD, self.build['id']) self._fail_deploy(deploy) deploys_helper.update_progress(commons.REQUEST, self.envName, PROD) data = {} data["type"] = "AUTO" data["disablePolicy"] = "MANUAL" data["predStage"] = CANARY data["failPolicy"] = "ROLLBACK" environs_helper.update_env_promotes_config(commons.REQUEST, self.envName, PROD, data=data) self._assertState(PROD, "MANUAL") new_env = environs_helper.get_env_by_stage(commons.REQUEST, self.envName, PROD) new_deploy = deploys_helper.get(commons.REQUEST, new_env['deployId']) new_build = builds_helper.get_build(commons.REQUEST, new_deploy['buildId']) self.assertEquals(new_build['commit'], commit_0) builds_helper.delete_build(commons.REQUEST, build_0['id']) deploys_helper.delete(commons.REQUEST, deploy_0['id']) deploys_helper.delete(commons.REQUEST, deploy['id']) deploys_helper.delete(commons.REQUEST, new_deploy['id']) # This so that we can delete the env environs_helper.update_env_capacity(commons.REQUEST, self.envName, PROD, capacity_type="HOST", data=[])
# See the License for the specific language governing permissions and # limitations under the License. # -*- coding: utf-8 -*- ''' This is a positive ping test to go through a success deploy ''' import unittest import time import commons import threading systems_helper = commons.get_system_helper() environs_helper = commons.get_environ_helper() deploys_helper = commons.get_deploy_helper() envName = "agent-test-env-" + commons.gen_random_num() stageName = "prod" commit = commons.gen_random_num(32) hostNamePrefix = "agent-test-host-" group = "agent-test-group-" + commons.gen_random_num() class TestPings(unittest.TestCase): def setUp(self): commons.create_env(envName, stageName) environs_helper.update_env_capacity(commons.REQUEST, envName, stageName, data=[group]) environs_helper.update_env_basic_config(commons.REQUEST, envName, stageName, {"maxParallel": 5}) environs_helper.update_env_script_config(commons.REQUEST, envName, stageName, {"s-c-n": "s-c-v"})
# See the License for the specific language governing permissions and # limitations under the License. # -*- coding: utf-8 -*- ''' This is a positive ping test to go through a success deploy ''' import unittest import time import commons import threading systems_helper = commons.get_system_helper() environs_helper = commons.get_environ_helper() deploys_helper = commons.get_deploy_helper() envName = "agent-test-env-" + commons.gen_random_num() stageName = "prod" commit = commons.gen_random_num(32) hostNamePrefix = "agent-test-host-" group = "agent-test-group-" + commons.gen_random_num() class TestPings(unittest.TestCase): def setUp(self): commons.create_env(envName, stageName) environs_helper.update_env_capacity(commons.REQUEST, envName, stageName, data=[group]) environs_helper.update_env_basic_config(commons.REQUEST, envName, stageName, {"maxParallel": 5})
def testDeploys(self): # test regular deploy deploy1 = deploys_helper.deploy(commons.REQUEST, TestDeploys.envName, CANARY, TestDeploys.buildId1) self.assertEquals(deploy1["envId"], TestDeploys.canaryEnvId) self.assertEquals(deploy1["buildId"], TestDeploys.buildId1) self.assertEquals(deploy1["type"], "REGULAR") self.assertNotEquals(deploy1["acceptanceStatus"], "ACCEPTED") self.assertEquals(deploy1["successTotal"], 0) self.assertEquals(deploy1["failTotal"], 0) self.assertEquals(deploy1["total"], 0) deploy2 = deploys_helper.deploy(commons.REQUEST, TestDeploys.envName, CANARY, TestDeploys.buildId2) self.assertEquals(deploy2["buildId"], TestDeploys.buildId2) # test query envIds = [TestDeploys.canaryEnvId, commons.gen_random_num()] deployResult = deploys_helper.get_all(commons.REQUEST, envId=envIds, oldestFirst=True, pageIndex=1, pageSize=1) self.assertEquals(deployResult["total"], 2) # TODO why we need truncated at all? self.assertTrue(deployResult["truncated"]) deploys = deployResult["deploys"] self.assertEquals(len(deploys), 1) self.assertEquals(deploy1["id"], deploys[0]["id"]) # test pause and resume deploys_helper.pause(commons.REQUEST, TestDeploys.envName, CANARY) envState = environs_helper.get_env_by_stage(commons.REQUEST, TestDeploys.envName, CANARY)['envState'] self.assertEquals(envState, "PAUSED") deploys_helper.resume(commons.REQUEST, TestDeploys.envName, CANARY) envState = environs_helper.get_env_by_stage(commons.REQUEST, TestDeploys.envName, CANARY)['envState'] self.assertEquals(envState, "NORMAL") # test restart deploy3 = deploys_helper.restart(commons.REQUEST, TestDeploys.envName, CANARY) self.assertEquals(deploy3["buildId"], TestDeploys.buildId2) self.assertEquals(deploy3["type"], "RESTART") # test rollback deploy4 = deploys_helper.rollback(commons.REQUEST, TestDeploys.envName, CANARY, deploy1["id"]) self.assertEquals(deploy4["buildId"], TestDeploys.buildId1) self.assertEquals(deploy4["type"], "ROLLBACK") # test promote deploy5 = deploys_helper.promote(commons.REQUEST, TestDeploys.envName, PROD, deploy4["id"]) self.assertEquals(deploy5["envId"], TestDeploys.prodEnvId) self.assertEquals(deploy5["buildId"], TestDeploys.buildId1) self.assertEquals(deploy5["type"], "REGULAR") self.assertEquals(deploy5["successTotal"], 0) self.assertEquals(deploy5["failTotal"], 0) self.assertEquals(deploy5["total"], 0) # delete all the deploys deploys_helper.delete(commons.REQUEST, deploy1["id"]) deploys_helper.delete(commons.REQUEST, deploy2["id"]) deploys_helper.delete(commons.REQUEST, deploy3["id"]) deploys_helper.delete(commons.REQUEST, deploy4["id"]) deploys_helper.delete(commons.REQUEST, deploy5["id"])