Skip to content

Commit

Permalink
Create new ruby file to set up new test env (#2169)
Browse files Browse the repository at this point in the history
Part of fix issue #2111

1.Create Keyword Setup Simple VC And Test Environment with Shared iSCSI Storage
2.Create Keyword Create Simple VC Cluster With Spec File
3.Create a new ruby file
4.Update test env in Group7-Upgrade cases to use this new test env
  • Loading branch information
luwang-vmware committed Nov 9, 2018
1 parent 9b250f9 commit bda87bf
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 8 deletions.
Expand Up @@ -26,8 +26,8 @@ ${new-ova-cert-path}= /storage/data/admiral/ca_download

*** Keywords ***
OVA Upgrade Setup
Setup Simple VC And Test Environment
Setup Simple VC And Test Environment with Shared iSCSI Storage

*** Test Cases ***
Upgrade OVA 1.2.1
Auto Upgrade OVA With Verification 7-01-UPGRADE-1-2-1 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} ha-datacenter
Auto Upgrade OVA With Verification 7-01-UPGRADE-1-2-1 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} dc1
Expand Up @@ -26,8 +26,8 @@ ${new-ova-cert-path}= /storage/data/admiral/ca_download

*** Keywords ***
OVA Upgrade Setup
Setup Simple VC And Test Environment
Setup Simple VC And Test Environment with Shared iSCSI Storage

*** Test Cases ***
Upgrade OVA 1.3.0
Auto Upgrade OVA With Verification 7-02-UPGRADE-1-3-0 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} ha-datacenter
Auto Upgrade OVA With Verification 7-02-UPGRADE-1-3-0 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} dc1
Expand Up @@ -26,8 +26,8 @@ ${new-ova-cert-path}= /storage/data/admiral/ca_download

*** Keywords ***
OVA Upgrade Setup
Setup Simple VC And Test Environment
Setup Simple VC And Test Environment with Shared iSCSI Storage

*** Test Cases ***
Upgrade OVA 1.3.1
Auto Upgrade OVA With Verification 7-03-UPGRADE-1-3-1 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} ha-datacenter
Auto Upgrade OVA With Verification 7-03-UPGRADE-1-3-1 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} dc1
Expand Up @@ -26,8 +26,8 @@ ${new-ova-cert-path}= /storage/data/admiral/ca_download

*** Keywords ***
OVA Upgrade Setup
Setup Simple VC And Test Environment
Setup Simple VC And Test Environment with Shared iSCSI Storage

*** Test Cases ***
Upgrade OVA 1.4.0
Auto Upgrade OVA With Verification 7-04-UPGRADE-1-4-0 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} ha-datacenter
Auto Upgrade OVA With Verification 7-04-UPGRADE-1-4-0 ${old-ova-file-name} ${old-ova-version} ${old-ova-cert-path} ${new-ova-cert-path} dc1
57 changes: 57 additions & 0 deletions tests/resources/Nimbus-Util.robot
Expand Up @@ -538,6 +538,63 @@ Create Simple VC Cluster With Static IP
Set Environment Variable TEST_TIMEOUT 15m
Set Test VC Variables

Setup Simple VC And Test Environment with Shared iSCSI Storage
# set up nimbus test bed and env variables
[Timeout] 50 minutes
Run Keyword And Ignore Error Nimbus Cleanup ${list} ${false}
# setup nimbus testbed
${esx1} ${esx2} ${vc} ${esx1-ip} ${esx2-ip} ${vc-ip}= Create Simple VC Cluster With Spec File spec=vic-cluster-2esxi-iscsi.rb
# set test variables
Set Suite Variable @{list} ${esx1} ${esx2} ${vc}
Set Environment Variable TEST_URL ${vc-ip}
Set Environment Variable TEST_USERNAME Administrator@vsphere.local
Set Environment Variable TEST_PASSWORD Admin\!23
Set Environment Variable BRIDGE_NETWORK bridge
Set Environment Variable PUBLIC_NETWORK vm-network
Set Environment Variable TEST_RESOURCE /dc1/host/cls
Set Environment Variable TEST_DATASTORE sharedVmfs-0
# set VC variables
Set Test VC Variables
# set VCH variables
Set Environment Variable DRONE_BUILD_NUMBER 0
Set Environment Variable VCH_TIMEOUT 20m0s
# set docker variables
# not using dind but host dockerd for these nightly tests
Set Global Variable ${DEFAULT_LOCAL_DOCKER} docker
Set Global Variable ${DEFAULT_LOCAL_DOCKER_ENDPOINT} unix:///var/run/docker.sock
# set harbor variables
Set Global Variable ${DEFAULT_HARBOR_PROJECT} default-project
# govc env variables
Set Environment Variable GOVC_URL %{TEST_URL}
Set Environment Variable GOVC_USERNAME %{TEST_USERNAME}
Set Environment Variable GOVC_PASSWORD %{TEST_PASSWORD}
Set Environment Variable GOVC_INSECURE 1
# check VC
Check VCenter

Create Simple VC Cluster With Spec File
[Arguments] ${spec}=vic-cluster-2esxi-iscsi.rb
[Timeout] 40 minutes

${name}= Evaluate 'vic-simple-cluster-' + str(random.randint(1000,9999)) modules=random

Log To Console Create a new simple vc cluster with spec ${spec}...
${out}= Deploy Nimbus Testbed %{NIMBUS_USER} %{NIMBUS_PASSWORD} spec=${spec} args=--noSupportBundles --plugin testng --vcvaBuild "${VC_VERSION}" --esxBuild "${ESX_VERSION}" --testbedName vic-simple-cluster --runName ${name}
Log ${out}

Log To Console Finished creating cluster ${name}

${out}= Execute Command ${NIMBUS_LOCATION} nimbus-ctl ip %{NIMBUS_USER}-${name}.vc.0 | grep %{NIMBUS_USER}-${name}.vc.0
${vc-ip}= Fetch From Right ${out} ${SPACE}

${out}= Execute Command ${NIMBUS_LOCATION} nimbus-ctl ip %{NIMBUS_USER}-${name}.esx.0 | grep %{NIMBUS_USER}-${name}.esx.0
${esx0-ip}= Fetch From Right ${out} ${SPACE}

${out}= Execute Command ${NIMBUS_LOCATION} nimbus-ctl ip %{NIMBUS_USER}-${name}.esx.1 | grep %{NIMBUS_USER}-${name}.esx.1
${esx1-ip}= Fetch From Right ${out} ${SPACE}

[Return] %{NIMBUS_USER}-${name}.esx.0 %{NIMBUS_USER}-${name}.esx.1 %{NIMBUS_USER}-${name}.vc.0 ${esx0-ip} ${esx1-ip} ${vc-ip}

Create Static IP Worker
Open Connection %{NIMBUS_GW}
Wait Until Keyword Succeeds 10 min 30 sec Login %{NIMBUS_USER} %{NIMBUS_PASSWORD}
Expand Down
123 changes: 123 additions & 0 deletions tests/resources/nimbus-testbeds/vic-cluster-2esxi-iscsi.rb
@@ -0,0 +1,123 @@
oneGB = 1 * 1000 * 1000 # in KB

$testbed = Proc.new do
{
"name" => "vic-iscsi-cluster",
"version" => 3,
"esx" => (0..1).map do | idx |
{
"name" => "esx.#{idx}",
"vc" => "vc.0",
'cpus' => 8,
'cpuReservation' => 2400,
"style" => "fullInstall",
"desiredPassword" => "e2eFunctionalTest",
"memory" => 16384, # 2x default
'memoryReservation' => 4096,
"disk" => [ 30 * oneGB],
"nics" => 2,
"iScsi" => ["iscsi.0"],
"clusterName" => "cls",
}
end,

"iscsi" => [
{
"name" => "iscsi.0",
"luns" => [200],
"iqnRandom" => "nimbus1"
}
],

"vcs" => [
{
"name" => "vc.0",
"type" => "vcva",
'cpuReservation' => 2400,
'memoryReservation' => 4096,
"dcName" => "dc1",
"clusters" => [{"name" => "cls", "vsan" => false, "enableDrs" => true, "enableHA" => true}],
"addHosts" => "allInSameCluster",
}
],

"postBoot" => Proc.new do |runId, testbedSpec, vmList, catApi, logDir|
esxList = vmList['esx']
esxList.each do |host|
host.ssh do |ssh|
ssh.exec!("esxcli network firewall set -e false")
end
end
vc = vmList['vc'][0]
vim = VIM.connect vc.rbvmomiConnectSpec
datacenters = vim.serviceInstance.content.rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter)
raise "Couldn't find a Datacenter precreated" if datacenters.length == 0
datacenter = datacenters.first
Log.info "Found a datacenter successfully in the system, name: #{datacenter.name}"
clusters = datacenter.hostFolder.children
raise "Couldn't find a cluster precreated" if clusters.length == 0
cluster = clusters.first
Log.info "Found a cluster successfully in the system, name: #{cluster.name}"

dvs = datacenter.networkFolder.CreateDVS_Task(
:spec => {
:configSpec => {
:name => "test-ds"
},
}
).wait_for_completion
Log.info "Vds DSwitch created"

dvpg1 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "management",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "management DPG created"

dvpg2 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "vm-network",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "vm-network DPG created"

dvpg3 = dvs.AddDVPortgroup_Task(
:spec => [
{
:name => "bridge",
:type => :earlyBinding,
:numPorts => 12,
}
]
).wait_for_completion
Log.info "bridge DPG created"

Log.info "Add hosts to the DVS"
onecluster_pnic_spec = [ VIM::DistributedVirtualSwitchHostMemberPnicSpec({:pnicDevice => 'vmnic1'}) ]
dvs_config = VIM::DVSConfigSpec({
:configVersion => dvs.config.configVersion,
:host => cluster.host.map do |host|
{
:operation => :add,
:host => host,
:backing => VIM::DistributedVirtualSwitchHostMemberPnicBacking({
:pnicSpec => onecluster_pnic_spec
})
}
end
})
dvs.ReconfigureDvs_Task(:spec => dvs_config).wait_for_completion
Log.info "Hosts added to DVS successfully"
end
}
end

0 comments on commit bda87bf

Please sign in to comment.