Skip to content

Commit

Permalink
Nested Tests: Stabilize agent locking and connectivity test (#5348)
Browse files Browse the repository at this point in the history
  • Loading branch information
and-rewsmith authored Aug 10, 2021
1 parent 677af9e commit b75ff85
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 12 deletions.
2 changes: 1 addition & 1 deletion builds/e2e/nested-connectivity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ stages:
- template: templates/nested-parent-vm-setup.yaml
parameters:
upstream.protocol: 'mqtt'
test.l4DeploymentFileName: 'nestededge_middleLayer_messaging_mqtt.json'
test.l4DeploymentFileName: 'nestededge_middleLayer_connectivity_mqtt.json'
- job: Deploy_Connectivity_Linux_Amd64
displayName: Set up and run connectivity tests on Linux Amd64
dependsOn:
Expand Down
2 changes: 1 addition & 1 deletion builds/e2e/nested-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ stages:
- template: templates/nested-deploy-config.yaml
parameters:
deviceId: $(parentDeviceId)
deploymentFile: nestededge_middleLayer_messaging_amqp.json
deploymentFile: nestededge_middleLayer_e2e_amqp.json
changeDeployConfigOnly: true
level: 4
name: 4
Expand Down
3 changes: 1 addition & 2 deletions builds/e2e/nested-longhaul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ stages:
displayName: Get ip address of L3 mqtt agent
name: get_l3_ip_mqtt
# Generate tracking id
- job: Generate_Tracking_Id
dependsOn:
- Lock_Nested_Agents_mqtt
Expand Down Expand Up @@ -88,7 +87,7 @@ stages:
- template: templates/nested-parent-vm-setup.yaml
parameters:
upstream.protocol: mqtt
test.l4DeploymentFileName: 'nestededge_middleLayer_messaging_mqtt.json'
test.l4DeploymentFileName: 'nestededge_middleLayer_long_haul_mqtt.json'
l3IpAddress: '$(l3IpAddressMqtt)'
test.trackingId: '$(trackingId)'
- template: templates/nested-longhaul-deploy-amd64.yaml
Expand Down
9 changes: 3 additions & 6 deletions builds/e2e/templates/lock-test-agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ jobs:
displayName: Lock nested agents for ${{ parameters['upstream.protocol'] }}
timeoutInMinutes: 180
pool:
name: $(pool.name)
demands:
- agent-group -equals $(agent.group)
- Agent.OS -equals Linux
- Agent.OSArchitecture -equals X64
- status -equals unlocked
name: $(pool.linux.name)
demands:
- ImageOverride -equals agent-aziotedge-ubuntu-18.04-docker
steps:
- template: nested-get-secrets.yaml
- script: scripts/linux/nestedAgentLock.sh -a "$(agent.group)" -b "$(Build.BuildId)" -n ${{ parameters['testRunnerCount'] }} -u ${{ parameters['upstream.protocol'] }}
Expand Down
5 changes: 5 additions & 0 deletions builds/e2e/templates/unlock-test-agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ steps:
--request PUT "https://msazure.visualstudio.com/_apis/distributedtask/pools/$POOL_ID/agents/$agentId/usercapabilities" \
-H "Content-Type:application/json" \
-H "Accept: application/json;api-version=5.0;" \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
--retry-connrefused \
--data @<(cat <<EOF
$newAgentUserCapabilities
EOF
Expand Down
134 changes: 134 additions & 0 deletions e2e_deployment_files/nestededge_middleLayer_connectivity_mqtt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"modulesContent": {
"$edgeAgent": {
"properties.desired": {
"schemaVersion": "1.1",
"runtime": {
"type": "docker",
"settings": {
"minDockerVersion": "v1.25",
"loggingOptions": "",
"registryCredentials": {
"buildcr": {
"username": "<CR.Username>",
"password": "<CR.Password>",
"address": "<Container_Registry>"
}
}
}
},
"systemModules": {
"edgeAgent": {
"type": "docker",
"settings": {
"image": "$upstream:443/microsoft/azureiotedge-agent:<Build.BuildNumber>-linux-<Architecture>",
"createOptions": "{\"HostConfig\":{\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{\"max-size\":\"4m\",\"max-file\":\"7\",\"compress\":\"true\"}}}}"
},
"env": {
"UpstreamProtocol": {
"value": "mqtt"
}
}
},
"edgeHub": {
"type": "docker",
"settings": {
"image": "$upstream:443/microsoft/azureiotedge-hub:<Build.BuildNumber>-linux-<Architecture>",
"createOptions": "{\"HostConfig\": {\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{\"max-size\":\"100m\",\"max-file\":\"7\"}}, \"PortBindings\": {\"8883/tcp\": [{\"HostPort\": \"8883\"}],\"5671/tcp\": [{\"HostPort\": \"5671\"}]}}}"
},
"env": {
"experimentalFeatures__enabled": {
"value": "true"
},
"experimentalFeatures__mqttBrokerEnabled": {
"value": "true"
},
"DeviceScopeCacheRefreshDelaySecs": {
"value": 0
},
"RuntimeLogLevel": {
"value": "debug"
},
"SslProtocols": {
"value": "tls1.2"
}
},
"status": "running",
"restartPolicy": "always"
}
},
"modules": {
"iotedgeApiProxy": {
"version": "1.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"startupOrder": 3,
"settings": {
"image": "$upstream:443/microsoft/azureiotedge-api-proxy:<Build.BuildNumber>-linux-<Architecture>",
"createOptions": "{\"HostConfig\": {\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{\"max-size\":\"4m\",\"max-file\":\"7\",\"compress\":\"true\"}}, \"PortBindings\": {\"443\/tcp\": [{\"HostPort\": \"443\"}]}}}"
},
"env": {
"NGINX_DEFAULT_PORT": {
"value": "443"
}
}
},
"genericMqttTester": {
"version": "1.0",
"type": "docker",
"status": "running",
"restartPolicy": "always",
"env": {
"TEST_SCENARIO": {
"value": "Relay"
},
"TEST_START_DELAY": {
"value": "1s"
},
"SslProtocols": {
"value": "tls1.2"
}
},
"settings": {
"image": "<Container_Registry>/microsoft/azureiotedge-generic-mqtt-tester:<Build.BuildNumber>-linux-<Architecture>",
"createOptions": "{\"HostConfig\":{\"LogConfig\":{\"Type\":\"json-file\",\"Config\":{\"max-size\":\"4m\",\"max-file\":\"7\",\"compress\":\"true\"}}}}"
}
}
}
}
},
"$edgeHub": {
"properties.desired": {
"schemaVersion": "1.2",
"routes": {
"ToUpstream": "FROM /messages/* INTO $upstream"
},
"storeAndForwardConfiguration": {
"timeToLiveSecs": 7200
},
"mqttBroker": {
"authorizations": [
{
"identities": [
"{{iot:identity}}"
],
"allow": [
{
"operations": [
"mqtt:connect",
"mqtt:publish",
"mqtt:subscribe"
],
"resources": [
"#"
]
}
]
}
]
}
}
}
}
}
11 changes: 9 additions & 2 deletions scripts/linux/nestedAgentLock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ process_args()
echo "Upstream protocol is a required parameter."
print_help_and_exit
fi

echo "Curl version: $(curl --version)"
}

###############################################################################
Expand Down Expand Up @@ -143,6 +145,11 @@ function update_capabilities() {
--request PUT "https://msazure.visualstudio.com/_apis/distributedtask/pools/$POOL_ID/agents/$agentId/usercapabilities" \
-H "Content-Type:application/json" \
-H "Accept: application/json;api-version=5.0;" \
--max-time 10 \
--retry 5 \
--retry-delay 0 \
--retry-max-time 40 \
--retry-connrefused \
--data @<(cat <<EOF
$newAgentUserCapabilities
EOF
Expand Down Expand Up @@ -230,9 +237,9 @@ startSeconds=$((SECONDS))
endSeconds=$((SECONDS + $TIMEOUT_SECONDS))
agentsNeeded=$(($RUNNER_AGENTS_NEEDED + 2))
while true && [ $((SECONDS)) -lt $endSeconds ]; do
# Wait 1-10 seconds to retry locking agents.
# Wait to retry locking agents.
# Random delay to avoid multiple instances of the script thrashing.
sleep $[ ( $RANDOM % 10 ) + 30 ]s
sleep $[ ( $RANDOM % 10 ) + 60 ]s

echo "Attempting to lock $agentsNeeded agents from the agent group $AGENT_GROUP..."
agentsInfo=$(curl -s -u :$PAT --request GET "https://dev.azure.com/msazure/_apis/distributedtask/pools/$POOL_ID/agents?includeCapabilities=true&api-version=$API_VER")
Expand Down

0 comments on commit b75ff85

Please sign in to comment.