This commit is contained in:
Omar Zevallos 2019-02-14 17:06:10 -05:00
Родитель 5e33c1b1ea
Коммит b27ee7516c
7 изменённых файлов: 217 добавлений и 65 удалений

Просмотреть файл

@ -86,19 +86,19 @@ jobs:
-k TestVfxtSupport \
--doctest-modules --junitxml=junit/test-results03.xml
CONTROLLER_IP=$(jq -r .controller_ip $VFXT_TEST_VARS_FILE)
PUBLIC_IP=$(jq -r .public_ip $VFXT_TEST_VARS_FILE)
CONTROLLER_NAME=$(jq -r .controller_name $VFXT_TEST_VARS_FILE)
CONTROLLER_USER=$(jq -r .controller_user $VFXT_TEST_VARS_FILE)
echo "CONTROLLER_IP : $CONTROLLER_IP"
echo "PUBLIC_IP : $PUBLIC_IP"
echo "CONTROLLER_NAME: $CONTROLLER_NAME"
echo "CONTROLLER_USER: $CONTROLLER_USER"
ARTIFACTS_DIR="$BUILD_SOURCESDIRECTORY/test_artifacts"
mkdir -p $ARTIFACTS_DIR
tar -zcvf ${ARTIFACTS_DIR}/vfxt_artifacts_${CONTROLLER_NAME}.tar.gz vfxt_artifacts_*
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r $CONTROLLER_USER@$CONTROLLER_IP:~/*.log $ARTIFACTS_DIR/.
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ~/.ssh/* $CONTROLLER_USER@$CONTROLLER_IP:~/.ssh/.
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r $CONTROLLER_USER@$PUBLIC_IP:~/*.log $ARTIFACTS_DIR/.
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ~/.ssh/* $CONTROLLER_USER@$PUBLIC_IP:~/.ssh/.
echo "vfxt.log from $CONTROLLER_NAME:"
cat $ARTIFACTS_DIR/vfxt.log

Просмотреть файл

@ -2,14 +2,22 @@
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"uniqueName": {
"type": "string",
"metadata": {
"description": "The unique name used as a basis for resource names."
}
},
"virtualNetworkName": {
"type": "string",
"defaultValue": "[concat(parameters('uniqueName'), '-vnet')]",
"metadata": {
"description": "The name of the virtual network (VNET)."
}
},
"virtualNetworkSubnetName": {
"type": "string",
"defaultValue": "[concat(parameters('uniqueName'), '-subnet')]",
"metadata": {
"description": "The name of the subnet in the VNET."
}
@ -27,13 +35,44 @@
"metadata": {
"description": "The IP address range prefix of the subnet in the VNET."
}
},
"jumpboxAdminUsername": {
"type": "string",
"defaultValue": "azureuser",
"metadata": {
"description": "The administrative username for the jumpbox."
}
},
"jumpboxSSHKeyData": {
"type": "string",
"metadata": {
"description": "The SSH public key used to connect to the jumpbox."
}
}
},
"variables": {
"vmSku": "Standard_A1",
"uniqueName": "[parameters('uniqueName')]",
"virtualNetworkName": "[parameters('virtualNetworkName')]",
"subnetName": "[parameters('virtualNetworkSubnetName')]",
"addressPrefix": "[parameters('vnetAddressSpacePrefix')]",
"subnetPrefix": "[parameters('subnetAddressRangePrefix')]"
"subnetPrefix": "[parameters('subnetAddressRangePrefix')]",
"subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]",
"publicIPAddressName": "[concat(variables('uniqueName'), '-publicip')]",
"storageAccountType": "Standard_LRS",
"jumpboxName": "[concat('jbox-', variables('uniqueName'))]",
"jumpboxSAName": "[concat(variables('uniqueName'), 'jbsa')]",
"jumpboxOSDiskName": "[concat(variables('jumpboxName'), '-osdisk')]",
"jumpboxIPConfigName": "[concat(variables('jumpboxName'), '-ipconfig')]",
"jumpboxNicName": "[concat(variables('jumpboxName'), '-nic')]",
"jumpboxSSHKeyPath": "[concat('/home/',parameters('jumpboxAdminUsername'),'/.ssh/authorized_keys')]",
"osType": {
"publisher": "Canonical",
"offer": "UbuntuServer",
"sku": "16.04-LTS",
"version": "latest"
},
"imageReference": "[variables('osType')]"
},
"resources": [
{
@ -61,28 +100,127 @@
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2017-10-01",
"properties": {
"publicIPAllocationMethod": "Static"
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('jumpboxNicName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2017-10-01",
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "[variables('jumpboxIPConfigName')]",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('jumpboxSAName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2015-06-15",
"properties": {
"accountType": "[variables('storageAccountType')]"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[variables('jumpboxName')]",
"location": "[resourceGroup().location]",
"apiVersion": "2017-03-30",
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/', variables('jumpboxSAName'))]",
"[concat('Microsoft.Network/networkInterfaces/', variables('jumpboxNicName'))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSku')]"
},
"osProfile": {
"computerName": "[variables('jumpboxName')]",
"adminUsername": "[parameters('jumpboxAdminUsername')]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[variables('jumpboxSSHKeyPath')]",
"keyData": "[parameters('jumpboxSSHKeyData')]"
}
]
}
}
},
"storageProfile": {
"imageReference": "[variables('imageReference')]",
"osDisk": {
"name": "[variables('jumpboxOSDiskName')]",
"caching": "ReadWrite",
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('jumpboxNicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat('http://',variables('jumpboxSAName'),'.blob.core.windows.net')]"
}
}
}
}
],
"outputs": {
"resource_group": {
"type": "string",
"value": "[resourceGroup().name]"
},
"location": {
"type": "string",
"value": "[resourceGroup().location]"
},
"virtual_network_name": {
"public_ip_address": {
"type": "string",
"value": "[variables('virtualNetworkName')]"
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))).ipAddress]"
},
"resource_group": {
"type": "string",
"value": "[resourceGroup().name]"
},
"subnet_id": {
"type": "string",
"value": "[concat(resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName')),'/subnets/',variables('subnetName'))]"
},
"subnet_name": {
"type": "string",
"value": "[variables('subnetName')]"
},
"subnet_id": {
"virtual_network_name": {
"type": "string",
"value": "[concat(resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName')),'/subnets/',variables('subnetName'))]"
"value": "[variables('virtualNetworkName')]"
}
}
}

Просмотреть файл

@ -123,7 +123,7 @@ def scp_cli(ssh_con):
@pytest.fixture()
def ssh_con(test_vars):
client = create_ssh_client(test_vars["controller_user"],
test_vars["controller_ip"],
test_vars["public_ip"],
key_filename=test_vars["ssh_priv_key"])
yield client
client.close()
@ -196,8 +196,13 @@ def test_vars(request):
@pytest.fixture()
def ext_vnet(test_vars):
"""
Creates a resource group containing a new VNET, subnet, public IP, and
jumpbox for use in other tests.
"""
log = logging.getLogger("ext_vnet")
vnet_atd = ArmTemplateDeploy(
location=test_vars["location"],
resource_group=test_vars["atd_obj"].deploy_id + "-vnet-rg"
)
rg = vnet_atd.create_resource_group()
@ -207,9 +212,14 @@ def ext_vnet(test_vars):
with open("{}/src/vfxt/azuredeploy.vnet.json".format(
test_vars["build_root"])) as tfile:
vnet_atd.template = json.load(tfile)
with open(test_vars["ssh_pub_key"], "r") as ssh_pub_f:
ssh_pub_key = ssh_pub_f.read()
vnet_atd.deploy_params = {
"virtualNetworkName": test_vars["atd_obj"].deploy_id + "-vnet",
"virtualNetworkSubnetName": test_vars["atd_obj"].deploy_id + "-subnet",
"uniqueName": test_vars["atd_obj"].deploy_id,
"jumpboxAdminUsername": "azureuser",
"jumpboxSSHKeyData": ssh_pub_key
}
test_vars["ext_vnet"] = wait_for_op(vnet_atd.deploy()).properties.outputs
log.debug(test_vars["ext_vnet"])

Просмотреть файл

@ -126,7 +126,7 @@ class TestEdasim:
log = logging.getLogger("test_edasim_run")
node_ip = test_vars["deploy_edasim_outputs"]["jobsubmitter_0_ip_address"]["value"]
with SSHTunnelForwarder(
test_vars["controller_ip"],
test_vars["public_ip"],
ssh_username=test_vars["controller_user"],
ssh_pkey=test_vars["ssh_priv_key"],
remote_bind_address=(node_ip, 22),

Просмотреть файл

@ -60,7 +60,7 @@ class TestVDBench:
log = logging.getLogger("test_vdbench_run")
node_ip = test_vars["deploy_vd_outputs"]["node_0_ip_address"]["value"]
with SSHTunnelForwarder(
test_vars["controller_ip"],
test_vars["public_ip"],
ssh_username=test_vars["controller_user"],
ssh_pkey=test_vars["ssh_priv_key"],
remote_bind_address=(node_ip, 22),

Просмотреть файл

@ -112,7 +112,7 @@ class TestVfxtSupport:
args=node)[node]["primaryClusterIP"]["IP"]
log.debug("tunneling to node {} using IP {}".format(node, node_ip))
with SSHTunnelForwarder(
test_vars["controller_ip"],
test_vars["public_ip"],
ssh_username=test_vars["controller_user"],
ssh_pkey=test_vars["ssh_priv_key"],
remote_bind_address=(node_ip, 22),

Просмотреть файл

@ -49,6 +49,7 @@ class TestVfxtTemplateDeploy:
}
test_vars["controller_name"] = atd.deploy_params["controllerName"]
test_vars["controller_user"] = atd.deploy_params["controllerAdminUsername"]
test_vars["storage_account"] = atd.deploy_params["avereBackedStorageAccountName"]
log.debug("Generated deploy parameters: \n{}".format(
json.dumps(atd.deploy_params, indent=4)))
@ -58,7 +59,51 @@ class TestVfxtTemplateDeploy:
test_vars["cluster_mgmt_ip"] = deploy_outputs["mgmt_ip"]["value"]
test_vars["cluster_vs_ips"] = split_ip_range(deploy_outputs["vserver_ips"]["value"])
finally:
test_vars["controller_ip"] = atd.nm_client.public_ip_addresses.get(
test_vars["public_ip"] = atd.nm_client.public_ip_addresses.get(
atd.resource_group, "publicip-" + test_vars["controller_name"]
).ip_address
def test_no_storage_account_deploy(self, resource_group, test_vars): # noqa: E501, F811
log = logging.getLogger("test_deploy_template")
atd = test_vars["atd_obj"]
with open("{}/src/vfxt/azuredeploy-auto.json".format(
test_vars["build_root"])) as tfile:
atd.template = json.load(tfile)
with open(test_vars["ssh_pub_key"], "r") as ssh_pub_f:
ssh_pub_key = ssh_pub_f.read()
atd.deploy_params = {
"adminPassword": os.environ["AVERE_ADMIN_PW"],
"avereClusterName": atd.deploy_id + "-cluster",
"avereInstanceType": "Standard_E32s_v3",
"avereNodeCount": 3,
"controllerAdminUsername": "azureuser",
"controllerAuthenticationType": "sshPublicKey",
"controllerName": atd.deploy_id + "-con",
"controllerPassword": os.environ["AVERE_CONTROLLER_PW"],
"controllerSSHKeyData": ssh_pub_key,
"enableCloudTraceDebugging": True,
"rbacRoleAssignmentUniqueId": str(uuid4()),
"createVirtualNetwork": True,
"virtualNetworkName": atd.deploy_id + "-vnet",
"virtualNetworkResourceGroup": atd.resource_group,
"virtualNetworkSubnetName": atd.deploy_id + "-subnet",
"useAvereBackedStorageAccount": False,
"avereBackedStorageAccountName": atd.deploy_id + "sa", # BUG
}
test_vars["controller_name"] = atd.deploy_params["controllerName"]
test_vars["controller_user"] = atd.deploy_params["controllerAdminUsername"]
log.debug("Generated deploy parameters: \n{}".format(
json.dumps(atd.deploy_params, indent=4)))
atd.deploy_name = "test_deploy_template"
try:
deploy_outputs = wait_for_op(atd.deploy()).properties.outputs
test_vars["cluster_mgmt_ip"] = deploy_outputs["mgmt_ip"]["value"]
test_vars["cluster_vs_ips"] = split_ip_range(deploy_outputs["vserver_ips"]["value"])
time.sleep(60)
finally:
test_vars["public_ip"] = atd.nm_client.public_ip_addresses.get(
atd.resource_group, "publicip-" + test_vars["controller_name"]
).ip_address
@ -91,47 +136,6 @@ class TestVfxtTemplateDeploy:
}
test_vars["controller_name"] = atd.deploy_params["controllerName"]
test_vars["controller_user"] = atd.deploy_params["controllerAdminUsername"]
test_vars["storage_account"] = atd.deploy_params["avereBackedStorageAccountName"]
log.debug("Generated deploy parameters: \n{}".format(
json.dumps(atd.deploy_params, indent=4)))
atd.deploy_name = "test_deploy_template"
try:
deploy_outputs = wait_for_op(atd.deploy()).properties.outputs
test_vars["cluster_mgmt_ip"] = deploy_outputs["mgmt_ip"]["value"]
test_vars["cluster_vs_ips"] = split_ip_range(deploy_outputs["vserver_ips"]["value"])
finally:
test_vars["controller_ip"] = atd.nm_client.public_ip_addresses.get(
atd.resource_group, "publicip-" + test_vars["controller_name"]
).ip_address
def test_no_storage_account_deploy(self, resource_group, test_vars): # noqa: F811
log = logging.getLogger("test_deploy_template")
atd = test_vars["atd_obj"]
with open("{}/src/vfxt/azuredeploy-auto.json".format(
test_vars["build_root"])) as tfile:
atd.template = json.load(tfile)
with open(test_vars["ssh_pub_key"], "r") as ssh_pub_f:
ssh_pub_key = ssh_pub_f.read()
atd.deploy_params = {
"avereInstanceType": "Standard_E32s_v3",
"avereClusterName": atd.deploy_id + "-cluster",
"virtualNetworkResourceGroup": atd.resource_group,
"virtualNetworkName": atd.deploy_id + "-vnet",
"virtualNetworkSubnetName": atd.deploy_id + "-subnet",
"avereBackedStorageAccountName": atd.deploy_id + "sa",
"controllerName": atd.deploy_id + "-con",
"controllerAdminUsername": "azureuser",
"controllerAuthenticationType": "sshPublicKey",
"controllerSSHKeyData": ssh_pub_key,
"controllerPassword": os.environ["AVERE_CONTROLLER_PW"],
"avereNodeCount": 3,
"adminPassword": os.environ["AVERE_ADMIN_PW"],
"rbacRoleAssignmentUniqueId": str(uuid4()),
"enableCloudTraceDebugging": True,
"useAvereBackedStorageAccount": False,
}
test_vars["controller_name"] = atd.deploy_params["controllerName"]
test_vars["controller_user"] = atd.deploy_params["controllerAdminUsername"]
log.debug("Generated deploy parameters: \n{}".format(
json.dumps(atd.deploy_params, indent=4)))
atd.deploy_name = "test_deploy_template_byovnet"
@ -140,11 +144,11 @@ class TestVfxtTemplateDeploy:
test_vars["cluster_mgmt_ip"] = deploy_outputs["mgmt_ip"]["value"]
test_vars["cluster_vs_ips"] = split_ip_range(deploy_outputs["vserver_ips"]["value"])
finally:
test_vars["controller_ip"] = atd.nm_client.public_ip_addresses.get(
atd.resource_group, "publicip-" + test_vars["controller_name"]
).ip_address
# test_vars["public_ip"] = atd.nm_client.public_ip_addresses.get(
# atd.resource_group, "publicip-" + test_vars["controller_name"]
# ).ip_address
pass
time.sleep(60)
if __name__ == "__main__":
pytest.main(sys.argv)