This commit is contained in:
Jonathan Goldstein 2018-12-12 22:17:42 -08:00
Родитель 579a6daad8 8bcd12ddda
Коммит 87cf9451a4
44 изменённых файлов: 644 добавлений и 232 удалений

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

@ -1,4 +1,4 @@
FROM ambrosia-dev as dev
FROM ambrosia/ambrosia-dev as dev
# The release does not require dotnet SDK to run Ambrosia binaries.
# So we start with a generic Ubuntu image:

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

@ -19,7 +19,7 @@ spec :
# hostNetwork: true
containers:
- name : perftest-server
image : ambrosia-perftest
image : ambrosia/ambrosia-perftest
imagePullPolicy : "Never"
ports:
- containerPort: 1500
@ -58,7 +58,7 @@ spec :
dnsPolicy: Default
containers:
- name : perftest-client
image : ambrosia-perftest
image : ambrosia/ambrosia-perftest
imagePullPolicy : "Never"
ports:
- containerPort: 1500

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

@ -20,8 +20,8 @@ else
fi
# Go and build the base images only if they are not found:
if [ "$($DOCKER images -q ambrosia-dev)" == "" ]; then
echo "Could not find 'ambrosia-dev' image, attempting to build it."
if [ "$($DOCKER images -q ambrosia/ambrosia-dev)" == "" ]; then
echo "Could not find 'ambrosia/ambrosia-dev' image, attempting to build it."
# Top of Ambrosia source working dir:
cd `dirname $0`/../../
DONT_BUILD_RELEASE_IMAGE=1 ./build_docker_images.sh

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

@ -1,8 +1,8 @@
# This Dockerfile demonstrates how we don't need to have the
# "ambrosia" Docker image as our *parent* in order to use AMBROSIA.
# "ambrosia/ambrosia" Docker image as our *parent* in order to use AMBROSIA.
# We can also just use it as a convenient way to grab binary releases
# of AMBROSIA.
# FROM ambrosia
# FROM ambrosia/ambrosia
#
# # We can use whatever we want as our parent image here:
# FROM ubuntu
@ -16,14 +16,14 @@
# COPY --from=ambrosia /ambrosia/bin /ambrosia/bin
# ----------------------------------------
# FROM ambrosia
# FROM ambrosia/ambrosia
# [2018.12.08] right now, running into:
# + Ambrosia RegisterInstance -i native1 --rp 50001 --sp 50002 -l ./ambrosia_logs/
# Error trying to upload service. Exception: Method not found: 'Remote.Linq.Expressions.Expression Remote.Linq.ExpressionTranslator.ToRemoteLinqExpression(System.Linq.Expressions.Expression, Aqua.TypeSystem.ITypeInfoProvider, System.Func`2<System.Linq.Expressions.Expression,Boolean>)'.
# Oh, that's happening even on ambrosia-dev:
FROM ambrosia-dev
# We get build dependencies from ambrosia-dev, since it built the native library.
# Oh, that's happening even on ambrosia/ambrosia-dev:
FROM ambrosia/ambrosia-dev
# We get build dependencies from ambrosia/ambrosia-dev, since it built the native library.
# RUN apt-get update && \
# apt-get install -y make gcc
# nmap

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

@ -1,5 +1,5 @@
# TODO: should migrate to depend only on 'ambrosia' not 'ambrosia-dev':
FROM ambrosia-dev
FROM ambrosia/ambrosia-dev
# For using Tmux inside the container:
# ------------------------------------------

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

@ -7,7 +7,7 @@ set -xeuo pipefail
# It is typically called WITHIN a docker container, like so:
#
# docker run -it --rm --env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" ambrosia-perftest ./run_PTI_in_tmux.sh
# docker run -it --rm --env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" ambrosia/ambrosia-perftest ./run_PTI_in_tmux.sh
#
# ------------------------------------------------------------------------------

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

@ -11,7 +11,7 @@ set -euo pipefail
# It should exit cleanly after the test is complete.
#
# This is often invoked within Docker:
# docker run -it --rm --env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" ambrosia-perftest ./run_small_PTI_and_shutdown.sh
# docker run -it --rm --env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" ambrosia/ambrosia-perftest ./run_small_PTI_and_shutdown.sh
#
# ------------------------------------------------------------------------------

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

@ -29,8 +29,8 @@ function DOCKRUN() {
docker run --rm --env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" $*
}
DOCKRUN ambrosia-perftest Ambrosia RegisterInstance -i $CLIENTNAME --rp $PORT1 --sp $PORT2 -l "/ambrosia_logs/"
DOCKRUN ambrosia-perftest Ambrosia RegisterInstance -i $SERVERNAME --rp $PORT3 --sp $PORT4 -l "/ambrosia_logs/"
DOCKRUN ambrosia/ambrosia-perftest Ambrosia RegisterInstance -i $CLIENTNAME --rp $PORT1 --sp $PORT2 -l "/ambrosia_logs/"
DOCKRUN ambrosia/ambrosia-perftest Ambrosia RegisterInstance -i $SERVERNAME --rp $PORT3 --sp $PORT4 -l "/ambrosia_logs/"
rm server.id || true
@ -39,12 +39,12 @@ rm server.id || true
# "C:/Users/../vendor/git-for-windows/", incorrectly reinterpreting the path on
# the host *host*. For now, simply assume they're in PATH:
DOCKRUN --env AMBROSIA_INSTANCE_NAME=$SERVERNAME --cidfile ./server.id \
ambrosia-perftest runAmbrosiaService.sh \
ambrosia/ambrosia-perftest runAmbrosiaService.sh \
Server --rp $PORT4 --sp $PORT3 -j $CLIENTNAME -s $SERVERNAME -n 1 -c &
sleep 10 # Clarifies output.
DOCKRUN --env AMBROSIA_INSTANCE_NAME=$CLIENTNAME ambrosia-perftest runAmbrosiaService.sh \
DOCKRUN --env AMBROSIA_INSTANCE_NAME=$CLIENTNAME ambrosia/ambrosia-perftest runAmbrosiaService.sh \
Job --rp $PORT2 --sp $PORT1 -j $CLIENTNAME -s $SERVERNAME --mms 65536 -n 2 -c
echo "Job docker image exited cleanly, killing the server one."
@ -56,6 +56,6 @@ docker ps
echo "TwoContainers test mode completed."
echo "Attempt a cleanup of our table metadata:"
DOCKRUN ambrosia-perftest UnsafeDeregisterInstance $CLIENTNAME || true
DOCKRUN ambrosia-perftest UnsafeDeregisterInstance $SERVERNAME || true
DOCKRUN ambrosia/ambrosia-perftest UnsafeDeregisterInstance $CLIENTNAME || true
DOCKRUN ambrosia/ambrosia-perftest UnsafeDeregisterInstance $SERVERNAME || true
echo "All done."

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

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

@ -49,21 +49,16 @@ set +x
# But first, we depend on the ambrosia-dev base image:
# Go and build the base images only if they are not found:
if [ "$($DOCKER images -q ambrosia-dev)" == "" ]; then
echo "Could not find 'ambrosia-dev' image, attempting to build it."
# Top of Ambrosia source working dir:
set -x
pushd `dirname $0`/../
./build_docker_images.sh
popd
set +x
if [ "$($DOCKER images -q ambrosia/ambrosia-dev)" == "" ]; then
echo "Could not find 'ambrosia/ambrosia-dev' image, attempting to fetch it."
docker pull ambrosia/ambrosia-dev
fi
echo "Building the service Docker container..."
echo "Building the user's application Docker container..."
pushd $SERVICE_SRC_PATH
set -x
$DOCKER build -t $DockerPrivateRegistry_URL/$AMBROSIA_CONTAINER_NAME .
$DOCKER tag $DockerPrivateRegistry_URL/$AMBROSIA_CONTAINER_NAME $AMBROSIA_CONTAINER_NAME
$DOCKER build -t $DockerPrivateRegistry_URL/$CONTAINER_NAME_ROOT .
$DOCKER tag $DockerPrivateRegistry_URL/$CONTAINER_NAME_ROOT $AMBROSIA_CONTAINER_NAME
set +x
popd
@ -72,9 +67,9 @@ popd
############################################
echo "Pushing the service Docker container..."
set -x
time $DOCKER push $DockerPrivateRegistry_URL/$AMBROSIA_CONTAINER_NAME
time $DOCKER push $DockerPrivateRegistry_URL/$CONTAINER_NAME_ROOT
$AZ acr repository list --name $ACR_NAME
$AZ acr repository show-tags --name $ACR_NAME --repository $AMBROSIA_CONTAINER_NAME
$AZ acr repository show-tags --name $ACR_NAME --repository $CONTAINER_NAME_ROOT
set +x
echo "-----------Build-and-Push Finished-----------"

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

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

@ -5,8 +5,6 @@ set -euo pipefail
# This script can be used to create a service principle which can then be used
# to create an image pull secret.
#
# Note: This is an alternative to giving direct access to ACS using the
# "Grant-AKS-acess-ACR.sh" script.
################################################################################
#Please see https://docs.microsoft.com/en-us/azure/container-registry/container-registry-auth-aks for more documentation

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

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

@ -22,6 +22,10 @@
# multiple instances, each of which contain multiple replicas).
AMBROSIA_SERVICE_NAME=perftest
# A fully-qualified container name IFF the container is already public and pullable.
# If unset, the scripts will build an image locally and push it to a private registry.
# PUBLIC_CONTAINER_NAME=ambrosia/ambrosia-perftest
# Find this in the Azure portal or with `az account list --output table`
AZURE_SUBSCRIPTION=PASTE_SUBSCRIPTION_ID_HERE
# Where to put resources we create:
@ -46,5 +50,18 @@ FILESHARE_NAME=ambrosia-logs-smbshare
FILESHARE_SECRET_NAME=azure-fileshare-secret
# ------------------------------------------------------------
# See Defs/Set-*.sh for variables that are retrieved automatically after login.
# Configuration parameters (can leave unchanged)
# ----------------------------------------------
# These relate to how many / how big the resources provisioned are.
# Values: Premium_LRS, Standard_GRS, Standard_LRS, Standard_RAGRS, Standard_ZRS
AZ_STORAGE_SKU=Standard_LRS
AZ_STORAGE_TIER=Hot # Hot or Cold
# Values: Basic, Classic, Premium, Standard
ACR_SKU=Standard
# Default is Standard_DS2_v2 (--node-vm-size)
AKS_VM_SIZE=Standard_DS4_v2
# See Defs/Set-*.sh for variables that are retrieved automatically after login.

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

@ -47,7 +47,10 @@ export AMBROSIA_CONTAINER_NAME
# These could be configurable, but we're setting boring defaults here instead:
PREFIX="ambrosia-"
POSTFIX="-container"
AMBROSIA_CONTAINER_NAME="${PREFIX}${AMBROSIA_SERVICE_NAME}${POSTFIX}"
if ! [ ${AMBROSIA_CONTAINER_NAME:+defined} ];
then AMBROSIA_CONTAINER_NAME="${PREFIX}${AMBROSIA_SERVICE_NAME}${POSTFIX}"
fi
export AMBROSIA_CONTAINER_NAME
export AMBROSIA_LOGDIR="/ambrosia_logs"

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

@ -21,7 +21,7 @@ shift
echo "-----------Begin Deploy-AKS ($AMBROSIA_INSTANCE_NAME)-----------"
source `dirname $0`/Defs/Common-Defs.sh
if [[ ! -v AZURE_STORAGE_CONNECTION_STRING ]]; then
if ! [ ${AZURE_STORAGE_CONNECTION_STRING:+defined} ]; then
echo "$0: AZURE_STORAGE_CONNECTION_STRING not set, retrieving:"
source `dirname $0`/Defs/Set-Storage-Vars.sh
fi
@ -45,12 +45,11 @@ SERVICE_YML_FILE="${UNIQUE_ID}${YMLEXTENSION}" # Need yml file to have unique d
echo "Registering Instance..."
set -x
function DOCKRUN() {
# FIXME: this should work with ambrosia, instead of ambrosia-dev, but right now [2018.11.29] it is producing an error:
# Error trying to upload service. Exception: One or more errors occurred. (The type initializer for 'System.Net.Http.CurlHandler' threw an exception
# TODO: this should work with ambrosia/ambrosia instead of ambrosia/ambrosia-dev
$DOCKER run --rm \
--env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" \
ambrosia-dev $*
# FIXME: bug 127 : --env AZURE_STORAGE_CONNECTION_STRING="$AZURE_STORAGE_CONNECTION_STRING" \
ambrosia/ambrosia-dev $*
# FIXME: VSTS bug 127 : --env AZURE_STORAGE_CONNECTION_STRING="$AZURE_STORAGE_CONNECTION_STRING" \
}
time DOCKRUN Ambrosia RegisterInstance -i $AMBROSIA_INSTANCE_NAME --rp $LOCALPORT1 --sp $LOCALPORT2 -l "$AMBROSIA_LOGDIR" --lts 1024
set +x
@ -64,12 +63,9 @@ source `dirname $0`/Defs/Set-Docker-Vars.sh
echo "Generating K8s Deployment YAML from Template...."
cp -f ScriptBits/lartemplate.yml $SERVICE_YML_FILE
sed -i "s/#CONTAINTERNAME#/${AMBROSIA_CONTAINER_NAME}/g" $SERVICE_YML_FILE
sed -i "s/#AMBROSIAINSTANCE#/${AMBROSIA_INSTANCE_NAME}/g" $SERVICE_YML_FILE
sed -i "s/#SERVICEEXEFILE#/${AMBROSIA_SERVICE_NAME}/g" $SERVICE_YML_FILE
sed -i "s/#DEPLOYMENTNAME#/${UNIQUE_ID}/g" $SERVICE_YML_FILE
sed -i "s/#REGISTRYURL#/${DockerPrivateRegistry_URL}/g" $SERVICE_YML_FILE
sed -i "s/#ACRSECRETNAME#/${ACR_SECRET_NAME}/g" $SERVICE_YML_FILE
sed -i "s/#FILESHARESECRETNAME#/${FILESHARE_SECRET_NAME}/g" $SERVICE_YML_FILE
sed -i "s/#FILESHARENAME#/${FILESHARE_NAME}/g" $SERVICE_YML_FILE
@ -77,6 +73,14 @@ sed -i "s/#COORDPORT#/${AMBROSIA_IMMORTALCOORDINATOR_PORT}/g" $SERVICE_YML_FILE
sed -i "s/#LOCALPORT1#/${LOCALPORT1}/g" $SERVICE_YML_FILE
sed -i "s/#LOCALPORT2#/${LOCALPORT2}/g" $SERVICE_YML_FILE
if [ ${PUBLIC_CONTAINER_NAME:+defined} ]; then
sed -i "s|- name: #ACRSECRETNAME#|## None Needed|" $SERVICE_YML_FILE
sed -i "s|#FULLCONTAINERNAME#|${PUBLIC_CONTAINER_NAME}|" $SERVICE_YML_FILE
else
sed -i "s|#ACRSECRETNAME#|${ACR_SECRET_NAME}|" $SERVICE_YML_FILE
sed -i "s|#FULLCONTAINERNAME#|${DockerPrivateRegistry_URL}/${CONTAINER_NAME_ROOT}|" $SERVICE_YML_FILE
fi
# Use an alternate delimiter because the string contains forward slash:
sed -i "s|#AZURECONNSTRING#|${AZURE_STORAGE_CONNECTION_STRING}|" $SERVICE_YML_FILE

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

@ -29,7 +29,9 @@ if [ "" == "$($AZ storage account list --output table --subscription $AZURE_SUBS
then
echo
set -x
time $AZ storage account create --name $AZURE_STORAGE_NAME -g $AZURE_RESOURCE_GROUP -l $AZURE_LOCATION
time $AZ storage account create --name $AZURE_STORAGE_NAME -g $AZURE_RESOURCE_GROUP -l $AZURE_LOCATION --sku $AZ_STORAGE_SKU
# "Account property accessTier is required for the request":
# --access-tier $AZ_STORAGE_TIER
set +x
else
echo "Storage account already exists, not creating. (az storage account list)"
@ -44,33 +46,43 @@ echo "--------Provision the file share if it does not exist--------"
echo "This step is idempotent:"
set -x
# TODO: May want to delete it to make sure the logs start fresh:
# $AZ storage share delete --name $FILESHARE_NAME --account-name $ACR_NAME --account-key="$AZURE_STORAGE_KEY"
$AZ storage share create --name $FILESHARE_NAME --quota "80" --account-name $ACR_NAME --account-key="$AZURE_STORAGE_KEY"
# $AZ storage share delete --name $FILESHARE_NAME
time $AZ storage share create --name $FILESHARE_NAME --quota "80" --account-name $AZURE_STORAGE_NAME --account-key="$AZURE_STORAGE_KEY"
# --connection-string="$AZURE_STORAGE_CONNECTION_STRING"
# Test the file share by uploading a file.
echo "Hello World" > hello.txt
time $AZ storage file upload -s $FILESHARE_NAME --source hello.txt
set +x
echo
echo "---------Provision the Container registry if needed---------"
if [ "" == "$($AZ acr list --output table --subscription $AZURE_SUBSCRIPTION -g $AZURE_RESOURCE_GROUP)" ];
then
set -x
# TODO: remove need for admin access here:
time $AZ acr create --name "$ACR_NAME" --resource-group "$AZURE_RESOURCE_GROUP" --sku Standard --admin-enabled true -l $AZURE_LOCATION
set +x
if [ ${PUBLIC_CONTAINER_NAME:+defined} ]; then
echo "---------PUBLIC_CONTAINER_NAME set, not using Azure container registry---------"
else
echo "Container registry already exists, not creating. (az acr list)"
echo
echo "---------Provision the Container registry if needed---------"
if [ "" == "$($AZ acr list --output table --subscription $AZURE_SUBSCRIPTION -g $AZURE_RESOURCE_GROUP)" ];
then
set -x
# TODO: remove need for admin access here:
time $AZ acr create --name "$ACR_NAME" --resource-group "$AZURE_RESOURCE_GROUP" \
--sku $ACR_SKU --admin-enabled true -l $AZURE_LOCATION
set +x
else
echo "Container registry already exists, not creating. (az acr list)"
fi
echo "Now log into the Azure Container Registry:"
set -x
$AZ acr login --name "$ACR_NAME"
set +x
fi
echo "Now log into the Azure Container Registry:"
set -x
$AZ acr login --name "$ACR_NAME"
set +x
echo
echo "--------Provision the Kubernetes Cluster if it's not already there--------"
if ! $AZ aks get-credentials --resource-group=$AZURE_RESOURCE_GROUP --name=$AZURE_KUBERNETES_CLUSTER 2>/dev/null ;
then
echo "Kubernetes cluster not found, creating."
set -x
time $AZ aks create --resource-group $AZURE_RESOURCE_GROUP --name=$AZURE_KUBERNETES_CLUSTER --node-count 2 --generate-ssh-keys -l $AZURE_LOCATION
time $AZ aks create --resource-group $AZURE_RESOURCE_GROUP --name=$AZURE_KUBERNETES_CLUSTER --node-count 2 --node-vm-size $AKS_VM_SIZE --generate-ssh-keys -l $AZURE_LOCATION
$AZ aks get-credentials --resource-group=$AZURE_RESOURCE_GROUP --name=$AZURE_KUBERNETES_CLUSTER
set +x
else

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

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

@ -18,7 +18,7 @@ spec :
- name: #ACRSECRETNAME#
containers:
- name : #DEPLOYMENTNAME#
image : #REGISTRYURL#/#CONTAINTERNAME#
image : #FULLCONTAINERNAME#
ports:
- containerPort: #COORDPORT#
name: craport

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

@ -1,6 +1,9 @@
#!/bin/bash
set -euo pipefail
# This example uses PerformanceTestInterruptable.
# See also the HelloWorld directory for a simpler example.
if [ ! -e Defs/AmbrosiaAKSConf.sh ]; then
echo "You're not ready yet! (Defs/AmbrosiaAKSConf.sh does not exist)"
echo
@ -24,16 +27,24 @@ echo
./Provision-Resources.sh
# STEPs 1-3: Secrets and Authentication
./Grant-AKS-access-ACR.sh
./Create-AKS-ServicePrincipal-Secret.sh # TODO: bypass if $servicePrincipalId/$servicePrincipalKey are set
source Defs/Common-Defs.sh # For PUBLIC_CONTAINER_NAME
if [ ${PUBLIC_CONTAINER_NAME:+defined} ]; then
echo "---------PUBLIC_CONTAINER_NAME set, not creating AKS/ACR auth setup---------"
else
./Grant-AKS-access-ACR.sh
./Create-AKS-ServicePrincipal-Secret.sh # TODO: bypass if $servicePrincipalId/$servicePrincipalKey are set
fi
./Create-AKS-SMBFileShare-Secret.sh
# STEP 4: Building and pushing Docker.
./Build-AKS.sh "../InternalImmortals/PerformanceTestInterruptible/"
if [ ${PUBLIC_CONTAINER_NAME:+defined} ]; then
echo "---------PUBLIC_CONTAINER_NAME set, NOT building Docker container locally---------"
else
./Build-AKS.sh "../../InternalImmortals/PerformanceTestInterruptible/"
fi
# STEP 5: Deploy two pods.
echo "-----------Pre-deploy cleanup-----------"
source Defs/Common-Defs.sh
echo "These are the secrets Kubernetes will use to access files/containers:"
$KUBE get secrets
echo
@ -43,19 +54,12 @@ time $KUBE delete pods,deployments -l app=generated-perftestclient
time $KUBE delete pods,deployments -l app=generated-perftestserver
$KUBE get pods
# Dummy version:
# ./Deploy-AKS.sh perftestserver 'while true; do sleep 1; echo server `date +%s`; done'
# ./Deploy-AKS.sh perftestclient 'while true; do sleep 1; echo client `date +%s`; done'
# [2018.12.03] If we run a DUMMY SERVICE here, the Coordinators do get to a "Ready" state.
./Deploy-AKS.sh perftestserver \
'runAmbrosiaService.sh Server --sp '$LOCALPORT1' --rp '$LOCALPORT2' -j perftestclient -s perftestserver -n 1 -c'
# 'runAmbrosiaService.sh sleep 99999999'
# 'runAmbrosiaService.sh yes'
./Deploy-AKS.sh perftestclient \
'runAmbrosiaService.sh Job --sp '$LOCALPORT1' --rp '$LOCALPORT2' -j perftestclient -s perftestserver --mms 65536 -n 13 -c'
# 'runAmbrosiaService.sh sleep 99999999'
set +x
echo "-----------------------------------------------------------------------"

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

@ -25,13 +25,23 @@ namespace Client1
protected override async Task<bool> OnFirstStart()
{
_server = GetProxy<IServerProxy>(_serverName);
_server.ReceiveMessageFork("Hello World 1!");
Console.WriteLine("Press any key to continue");
Console.ReadKey();
_server.ReceiveMessageFork("Hello World 2!");
_server.ReceiveMessageFork("Hello World 3!");
Console.WriteLine("Press any key to end");
Console.ReadKey();
_server.ReceiveMessageFork("\n!! Client: Hello World 1!");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\n!! Client: Sent message 1.");
Console.WriteLine("\n!! Client: Press enter to continue (will send 2&3)");
Console.ResetColor();
Console.ReadLine(); // Console.ReadKey();
_server.ReceiveMessageFork("\n!! Client: Hello World 2!");
_server.ReceiveMessageFork("\n!! Client: Hello World 3!");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("\n!! Client: Press enter to shutdown.");
Console.ReadLine(); // Console.ReadKey();
Program.finishedTokenQ.Enqueue(0);
return true;
}

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

@ -1,8 +1,8 @@
# ------------------------------
FROM ambrosia
FROM ambrosia/ambrosia as amb
FROM microsoft/dotnet:2.0-sdk
COPY --from=ambrosia /ambrosia/bin /ambrosia/bin
COPY --from=amb /ambrosia/bin /ambrosia/bin
ENV PATH="$PATH:/ambrosia/bin"
# ------------------------------

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

@ -12,13 +12,13 @@ Get-ChildItem "CodeGenDependencies\netcoreapp2.0\" | Remove-Item
Write-Host "Using variant of CodeGen.exe: $env:AMBVARIANT"
Write-Host "Executing codegen command: dotnet $ambrosiaPath\Clients\CSharp\AmbrosiaCS\bin\$env:AMBVARIANT\AmbrosiaCS.dll CodeGen -a=ServerAPI\bin\$env:AMBVARIANT\IServer.dll -o=ServerInterfaces -f=netcoreapp2.0 -b=CodeGenDependencies\netcoreapp2.0"
Write-Host "Executing codegen command: dotnet $env:AMBROSIATOOLS\x64\Release\netcoreapp2.0\AmbrosiaCS.dll CodeGen -a=ServerAPI\bin\$env:AMBVARIANT\IServer.dll -o=ServerInterfaces -f=netcoreapp2.0 -b=CodeGenDependencies\netcoreapp2.0"
Write-Host "Executing codegen command: dotnet $ambrosiaPath\Clients\CSharp\AmbrosiaCS\bin\$env:AMBVARIANT\AmbrosiaCS.dll CodeGen -a=IClient1\bin\$env:AMBVARIANT\IClient1.dll -o=Client1Interfaces -f=netcoreapp2.0 -b=CodeGenDependencies\netcoreapp2.0"
Write-Host "Executing codegen command: dotnet $env:AMBROSIATOOLS\x64\Release\netcoreapp2.0\AmbrosiaCS.dll CodeGen -a=ServerAPI\bin\$env:AMBVARIANT\IServer.dll -a=IClient1\bin\$env:AMBVARIANT\IClient1.dll -o=Client1Interfaces -f=netcoreapp2.0 -b=CodeGenDependencies\netcoreapp2.0"
Write-Host "Executing codegen command: dotnet $ambrosiaPath\Clients\CSharp\AmbrosiaCS\bin\$env:AMBVARIANT\AmbrosiaCS.dll CodeGen -a=IClient2\bin\$env:AMBVARIANT\IClient2.dll -o=Client2Interfaces -f=netcoreapp2.0 -b=CodeGenDependencies\netcoreapp2.0"
Write-Host "Executing codegen command: $env:AMBROSIATOOLS\x64\Release\netcoreapp2.0\AmbrosiaCS.dll CodeGen -a=ServerAPI\bin\$env:AMBVARIANT\IServer.dll -a=IClient2\bin\$env:AMBVARIANT\IClient2.dll -o=Client2Interfaces -f=netcoreapp2.0 -b=CodeGenDependencies\netcoreapp2.0"
# Generate the assemblies, assumes an .exe which is created by a .Net Framework build:
& dotnet $ambrosiaPath\Clients\CSharp\AmbrosiaCS\bin\$env:AMBVARIANT\AmbrosiaCS.dll CodeGen -a="ServerAPI\bin\$env:AMBVARIANT\IServer.dll" -o=ServerInterfaces -f="netcoreapp2.0" -b="CodeGenDependencies\netcoreapp2.0"
& dotnet $ambrosiaPath\Clients\CSharp\AmbrosiaCS\bin\$env:AMBVARIANT\AmbrosiaCS.dll CodeGen -a="ServerAPI\bin\$env:AMBVARIANT\IServer.dll" -a="IClient1\bin\$env:AMBVARIANT\IClient1.dll" -o=Client1Interfaces -f="netcoreapp2.0" -b="CodeGenDependencies\netcoreapp2.0"
& dotnet $ambrosiaPath\Clients\CSharp\AmbrosiaCS\bin\$env:AMBVARIANT\AmbrosiaCS.dll CodeGen -a="ServerAPI\bin\$env:AMBVARIANT\IServer.dll" -a="IClient2\bin\$env:AMBVARIANT\IClient2.dll" -o=Client2Interfaces -f="netcoreapp2.0" -b="CodeGenDependencies\netcoreapp2.0"
& dotnet $env:AMBROSIATOOLS\x64\Release\netcoreapp2.0\AmbrosiaCS.dll CodeGen -a="ServerAPI\bin\$env:AMBVARIANT\IServer.dll" -o=ServerInterfaces -f="netcoreapp2.0" -b="CodeGenDependencies\netcoreapp2.0"
& dotnet $env:AMBROSIATOOLS\x64\Release\netcoreapp2.0\AmbrosiaCS.dll CodeGen -a="ServerAPI\bin\$env:AMBVARIANT\IServer.dll" -a="IClient1\bin\$env:AMBVARIANT\IClient1.dll" -o=Client1Interfaces -f="netcoreapp2.0" -b="CodeGenDependencies\netcoreapp2.0"
& dotnet $env:AMBROSIATOOLS\x64\Release\netcoreapp2.0\AmbrosiaCS.dll CodeGen -a="ServerAPI\bin\$env:AMBVARIANT\IServer.dll" -a="IClient2\bin\$env:AMBVARIANT\IClient2.dll" -o=Client2Interfaces -f="netcoreapp2.0" -b="CodeGenDependencies\netcoreapp2.0"

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

@ -7,10 +7,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AmbrosiaLibCS" Version="2018.12.12.1" />
<PackageReference Include="CRA" Version="2018.11.5.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Scripting" Version="2.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="15.8.168" />
<PackageReference Include="Mono.Options.Core" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Remote.Linq" Version="5.8.1" />
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Update="Microsoft.NETCore.App=" Version="2.0.0=" />
</ItemGroup>
</Project>

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

@ -7,10 +7,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AmbrosiaLibCS" Version="2018.12.12.1" />
<PackageReference Include="CRA" Version="2018.11.5.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Scripting" Version="2.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="15.8.168" />
<PackageReference Include="Mono.Options.Core" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Remote.Linq" Version="5.8.1" />
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Update="Microsoft.NETCore.App=" Version="2.0.0=" />
</ItemGroup>
</Project>

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

@ -7,10 +7,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="AmbrosiaLibCS" Version="2018.12.12.1" />
<PackageReference Include="CRA" Version="2018.11.5.1" />
<PackageReference Include="Microsoft.CodeAnalysis.Scripting" Version="2.7.0" />
<PackageReference Include="Microsoft.VisualStudio.Threading" Version="15.8.168" />
<PackageReference Include="Mono.Options.Core" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Remote.Linq" Version="5.8.1" />
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
<PackageReference Update="Microsoft.NETCore.App=" Version="2.0.0=" />
</ItemGroup>
</Project>

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

@ -0,0 +1,106 @@
Building and Running: dotnet CLI + Bash
=======================================
This tutorial assumes you are using a Bash shell together with the
`dotnet` CLI (2.0 or greater). The commands here should work on Mac
OS, Linux, and Windows.
Building
--------
To build everything, make sure the AMBROSIA binary distrubition is in
your PATH (e.g. `which AmbrosiaCS`) and run the script:
./build_dotnetcore.sh
Now you have binaries built under the paths `Server/publish`,
`Client1/publish`, and `Client2/publish`. The two clients are
*different* examples, and only one or the other should be run at a time.
Running
-------
### Super quickstart for the impatient
If you're feeling lucky, you can try running the setting
AZURE_STORAGE_CONN_STRING and then running two communicating services
locally in one terminal like so:
./run_helloworld_both.sh
Or you can tease it apart and open the client and server separately,
in separate terminal windows:
./run_helloworld_client.sh
./run_helloworld_server.sh
After you run, you'll want to cleanup the logs (`ambrosia_logs/`)
before running again, or the system will think it's recovering from a
failure and still part of the previous run.
### Longer version
In order to develop your own AMBROSIA services we'll need to walk
through the steps in a bit more detail. There are three main steps.
#### (Steps 1/3) Registering
Before we can run the client/server, we need to register metadata
about these AMBROSIA instances with in the cloud table storage. Pick
a name for your client and server instances.
Ambrosia RegisterInstance -i myclient --rp 1000 --sp 1001 -l ./ambrosia_logs
Ambrosia RegisterInstance -i myserver --rp 2000 --sp 2001 -l ./ambrosia_logs
We've told AMBROSIA that it will use `./ambrosia_logs` for storing
logs locally, but in a production environment of course logs would
need to be on a remotely-mounted file system that is durable even when
the machine fails.
#### (Step 2/3) Running an instance.
First let's run the server. Open a terminal, and let's set up some of
the configuration information that will be used by the
`runAmbrosiaService.sh` script to launch your process.
export AMBROSIA_INSTANCE_NAME=myserver
export AMBROSIA_IMMORTALCOORDINATOR_PORT=2500
export AZURE_STORAGE_CONN_STRING=...
To launch a service we're going to use a convenience script called
`runAmbrosiaService.sh` which is included in the binary distribution
of AMBROSIA. This handles starting the immortal coordinator and
monitorying its health.
runAmbrosiaService.sh dotnet Server/publish/Server.dll myserver
You'll see a lot of output, with output from the coordinator tagged
`[ImmortalCoord]`. Eventually, the coordinator reports "Ready" and
Alternatively, you could start ImmortalCoordinator yourself, by using
two separate terminals to run:
ImmortalCoordinator -i myserver -p 2500
dotnet Server/publish/Server.dll myserver
#### Running another instance.
Now you have the server running, but for this to be interesting, we
need another client to connect to the server.
export AMBROSIA_INSTANCE_NAME=myclient
export AMBROSIA_IMMORTALCOORDINATOR_PORT=1500
export AZURE_STORAGE_CONN_STRING=...
runAmbrosiaService.sh dotnet Client1/Publish/Client1.dll myclient myserver
#### (Step 3/3) Cleanup
To delete all the metadata we left in the cloud, run the following:
UnsafeDeregisterInstance myclient
UnsafeDeregisterInstance myserver
Note this is called "unsafe" because one must take great care to not
call it while any part of the service may still be running.

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

@ -0,0 +1,69 @@
Building and Running: Docker, Kubernets, AKS
============================================
Running HelloWorld on Docker Locally
------------------------------------
For this example you need the "ambrosia" Docker image. You can pull
it from Dockerhub:
docker pull ambrosia/ambrosia
Or you can build it locally by checking out the source:
git clone git@github.com:Microsoft/AMBROSIA
cd AMBROSIA
./build_docker_images.sh
Test it out by executing `docker run -it --rm ambrosia/ambrosia`. Now
you're ready to build the HelloWorld example in this directory:
docker build -t ambrosia-hello .
With that, you can run the example in one container:
docker run -it --rm --env "AZURE_STORAGE_CONN_STRING=$AZURE_STORAGE_CONN_STRING" ./run_helloworld_both.sh
Or you can run two containers that communicate with eachother. First
set AZURE_STORAGE_CONN_STRING and register the instances (locally or
inside the ambrosia container):
Ambrosia RegisterInstance -i myclient --rp 1000 --sp 1001 -l ./ambrosia_logs
Ambrosia RegisterInstance -i myserver - -rp 2000 --sp 2001 -l ./ambrosia_logs
Then open up two terminals, and spawn the server container:
docker run -it --rm --env "AZURE_STORAGE_CONN_STRING=$AZURE_STORAGE_CONN_STRING" ambrosia-hello ./run_helloworld_server.sh
Followed by the client container:
docker run -it --rm --env "AZURE_STORAGE_CONN_STRING=$AZURE_STORAGE_CONN_STRING" ambrosia-hello ./run_helloworld_client.sh
Press a key on the client container to continue.
Running HelloWorld on Kubernetes using AKS
------------------------------------------
We can take the same Docker containers we used above and deploy them
into a Kubernetes cluster in the cloud. In this example we use the
Azure Kubernetes Service (AKS).
For this step, you'll need a full source checkout of the AMBROSIA
repository (e.g. use the git clone command above). Within that
working copy, should read through the documentation [in the
AKS-scripts directory](../../AKS-scripts) before continuing here.
Back? Ok, let's proceed.
After you've populated AmbrosiaAKSConf.sh and have things working
within the AKS-scripts directory. Within that config file, set:
AMBROSIA_SERVICE_NAME=hello
And now:
./run_helloworld_aks.sh

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

@ -12,13 +12,12 @@ As part of a full build, Ambrosia generates code for the interface proxies. To m
### Getting the Ambrosia tool binaries
To run the application you'll need the Ambrosia tools that are distributed in compressed folder. To get these,
To run HelloWorld you'll also need the Ambrosia tools that are distributed in compressed folder. To get these,
- Download the compressed folder (either `Ambrosia-win.zip` or `Ambrosa-linux.tgz`)
- Download the compressed folder `Ambrosia-win.zip`
- Unpack it somewhere on your disk; for example, `C:\Ambrosia-win\`
- Set the `%AMBROSIATOOLS%` environment variable to point to that directory
## Running HelloWorld
For the purpose of this tutorial, we'll assume the following parameters:
@ -50,42 +49,41 @@ dotnet Ambrosia.dll RegisterInstance -i=server -rp=2000 -sp=2001 -l=C:\logs\
You should see messages "The CRA instance appears to be down. Restart it and this vertex will be instantiated automatically". That means everything is working as expected! We have not started those instances yet - once we start them they'll register automatically.
### Running the application (client 1)
### Running the application
To run the HelloWorld application, you will need to run four command-line
processes, each in a separate window: the HelloWorld client Immortal, the
processes, each in a separate console window: the HelloWorld client Immortal, the
HelloWorld server Immortal, and two ImmortalCoordinator processes, one for
each Immortal.
To run the client ImmortalCoordinator, open a command prompt and enter these
commands:
```bat
cd %AMBROSIATOOLS%\x64\Release\netcoreapp2.0
dotnet ImmortalCoordinator.dll --instanceName=client --port=1500
```
To run the server ImmortalCoordinator:
To run the server ImmortalCoordinator, in the first console window:
```bat
cd %AMBROSIATOOLS%\x64\Release\netcoreapp2.0
dotnet ImmortalCoordinator.dll --instanceName=server --port=2500
```
To run the HelloWorld client:
To run the client ImmortalCoordinator, in the second console window:
```bat
cd Client1\bin\x64\Debug\netcoreapp2.0
dotnet Client1.dll
cd %AMBROSIATOOLS%\x64\Release\netcoreapp2.0
dotnet ImmortalCoordinator.dll --instanceName=client --port=1500
```
To run the HelloWorld server:
To run the HelloWorld server, in the third console window:
```bat
cd Server\bin\x64\Debug\netcoreapp2.0
dotnet Server.dll
```
To run the HelloWorld client, in the fourth console window:
```bat
cd Client1\bin\x64\Debug\netcoreapp2.0
dotnet Client1.dll
```
After starting all four processes, you should see your client and server
communicate with each other! Specifically:
@ -95,55 +93,29 @@ communicate with each other! Specifically:
- The console of the server process prints `Received message from a client: Hello World 2!`
- The console of the server process prints `Received message from a client: Hello World 3!`
### Clearing state and re-running
If you want to run Hello World a second time, it is not enough to just restart the immortals! They will just resume running where they left off (at the end of Hello World). So, to start over, you have to clear the state. It's simple:
If you want to run Hello World a second time, it is not enough to just restart the immortals! They will just resume running where they left off (at the end of Hello World, or wherever else they were). So, to start over, you have to clear the state. It's simple:
- Delete the contents of the `C:\logs` directory.
Optionally, you can also delete the registrations in the Azure table:
### Running the application w/ interrupt
```bat
cd %AMBROSIATOOLS%\x64\Release\netcoreapp2.0\
dotnet UnsafeDeregisterInstance.dll server
dotnet UnsafeDeregisterInstance.dll client
```
(TODO)
### Running the application (client 2)
(TODO)
Of course, if you delete those, you have to re-register them in order to run HelloWorld again.
## Full Build w/ Code Generation
Ambrosia generates code for the interface proxies. To make this sample easy to run, we have already included the generated code, so you don't have to run code generation just to build and run the HelloWorld sample. However, if you want to experiment with it or make any changes to the interfaces, here is how you can run the code generation step.
The code generation step requires the Ambrosia tools that are distributed in compressed folder. So before running code generation the first time: (1) Download the tools (either Ambrosia-win.zip or Ambrosa-linux.tgz), (2) Unpack them somewhere on your disk, and (3) edit the powershell script Generate-Assemblies-NetCore.ps1 to use the correct path to that directory.
Once you have set up the script, here is how you run or re-run code generation:
1. Build the projects `IClient1`, `IClient2` and `IServer`. This generates the binaries used by the code generation step.
2. Run code generation by executing `Generate-Assemblies-NetCore.ps1`. This overwrites the content of the projects `Client1Interfaces`, `Client2Interfaces` and `ServerInterfaces` with generated code.
**CURRENTLY BROKEN :(**
```
Unhandled Exception: System.IO.FileNotFoundException: Could not find file 'C:\home\git\ambrosia\Samples\HelloWorld\CodeGenDependencies\netcoreapp2.0\A
mbrosiaCS.csproj'.
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
at System.Xml.XmlTextReaderImpl.FinishInitUriString()
at System.Xml.XmlTextReaderImpl..ctor(String uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(String inputUri, XmlReaderSettings settings)
at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
at Ambrosia.Program.RunCodeGen() in D:\a\1\s\Clients\CSharp\AmbrosiaCS\Program.cs:line 162
at Ambrosia.Program.Main(String[] args) in D:\a\1\s\Clients\CSharp\AmbrosiaCS\Program.cs:line 31
```
3. Build HelloWorld.sln. This now picks up the freshly generated source files.

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

@ -2,66 +2,18 @@
AMBROSIA Sample Application: Hello World
========================================
This application ....
This sample shows two immortals communicating, a client and a server. You can build and run it locally to get a quick idea of how Ambrosia operates. The solution contains two alternate versions of the client (Client1 and Client2), only one of which is used at a time. Client1 demonstrates basic communication, while Client2 demonstrates nondeterministic input using an impulse handler.
<FINISHME>
To run it yourself, refer to the version of the tutorial that matches
your tooling environment:
Building and Running: CLI and .NET Core
---------------------------------------
* [HOWTO-WINDOWS.md](./HOWTO-WINDOWS.md): Build and run using
Windows-native tooling, e.g. Visual Studio and `cmd.exe`.
To build everything, make sure the AMBROSIA binary distrubition is in
your PATH (e.g. `which AmbrosiaCS`) and run the script:
* [HOWTO-BASH.md](./HOWTO-BASH.md): Build and run on your local
machine (Mac, Windows, Linux) using Bash scripts.
./build_dotnetcore.sh
Now you have binaries built under the paths `Server/publish`,
`Client1/publish`, and `Client2/publish`. The two clients are
*different* examples, and only one or the other should be run at a time.
Before we can run the client/server, we need to register metadata
about these AMBROSIA instances with in the cloud table storage. Pick
a name for your client and server instances.
Ambrosia RegisterInstance -i myclient --rp 2000 --sp 2001 -l locallogs
Ambrosia RegisterInstance -i myserver --rp 2000 --sp 2001 -l locallogs
We've told AMBROSIA that it will use `./locallogs` for storing logs,
but in a production environment of course logs would need to be on a
remotely-mounted file system that is durable even when the machine fails.
First let's run the server. Open a terminal, and let's set up some of
the configuration information that will be used by the
`runAmbrosiaService.sh` script to launch your process.
export AMBROSIA_INSTANCE_NAME=myclient
export AMBROSIA_IMMORTALCOORDINATOR_PORT=1500
export AZURE_STORAGE_CONN_STRING=...
To launch a service we're going to use a convenience script called
`runAmbrosiaService.sh` which is included in the binary distribution
of AMBROSIA. This handles starting the immortal coordinator and
monitorying its health. (You could start ImmortalCoordinator
yourself, as well
Building and Running: Docker
----------------------------
docker run -it --rm --env "AZURE_STORAGE_CONN_STRING=$AZURE_STORAGE_CONN_STRING" \
--env --env "AMBROSIA_IMMORTALCOORDINATOR_PORT=1600" \
ambrosia-hello runAmbrosiaService.sh dotnet Client2/publish/Client2.dll $CNAME $SNAME
Building and Running: Windows / Visual Studio
---------------------------------------------
<FINISHME> - move from AmbrosiaDocs.md??
* [HOWTO-DOCKER-K8S.md](./HOWTO-DOCKER-K8S.md): Build and run inside
containers using Docker.

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

@ -21,7 +21,10 @@ namespace Server
public async Task<int> ReceiveMessageAsync(string message)
{
Console.WriteLine("Received message from a client: " + message);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("\n!! SERVER Received message from a client: " + message);
Console.ResetColor();
_messagesReceived++;
return _messagesReceived;
}

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

@ -0,0 +1,65 @@
#!/bin/bash
set -euo pipefail
cd `dirname $0`
HELLOTOP=`pwd`
cd ../../AKS-scripts
if [ ! -e Defs/AmbrosiaAKSConf.sh ]; then
echo "You're not ready yet! (Defs/AmbrosiaAKSConf.sh does not exist)"
echo
echo "This script demonstrates the full process of provisioning and deploying AMBROSIA on K8s."
echo "The only configuration needed is to fill out Defs/AmbrosiaAKSConf.sh.template"
echo
echo "Please follow the instructions in README.md and in that template file."
echo
exit 1
fi
echo "$0: Provision and run an AMBROSIA app on Azure Kubernetes Service"
echo "Running with these user settings:"
( export ECHO_CORE_DEFS=1; source `dirname $0`/Defs/Common-Defs.sh)
echo
# This should perform IDEMPOTENT OPERATIONS
#------------------------------------------
# STEP 0: Create Azure resources.
./Provision-Resources.sh
# STEPs 1-3: Secrets and Authentication
./Grant-AKS-access-ACR.sh
./Create-AKS-ServicePrincipal-Secret.sh # TODO: bypass if $servicePrincipalId/$servicePrincipalKey are set
./Create-AKS-SMBFileShare-Secret.sh
# STEP 4: Building and pushing Docker.
./Build-AKS.sh "."
# STEP 5: Deploy two pods.
echo "-----------Pre-deploy cleanup-----------"
source Defs/Common-Defs.sh
echo "These are the secrets Kubernetes will use to access files/containers:"
$KUBE get secrets
echo
echo "Deleting all pods in this test Kubernetes instance before redeploying"
$KUBE get pods
time $KUBE delete pods,deployments -l app=generated-helloclient
time $KUBE delete pods,deployments -l app=generated-helloserver
$KUBE get pods
export LOCALPORT1=2000
export LOCALPORT2=2001
./Deploy-AKS.sh helloserver 'runAmbrosiaService.sh dotnet Client1/Publish/Client1.dll helloclient helloserver'
export LOCALPORT1=1000
export LOCALPORT2=1001
./Deploy-AKS.sh helloclient 'runAmbrosiaService.sh dotnet Server/publish/Server.dll helloserver'
set +x
echo "-----------------------------------------------------------------------"
echo " ** End-to-end AKS / Kubernetes test script completed successfully. ** "
echo
source `dirname $0`/Defs/Common-Defs.sh
echo "P.S. If you want to delete the ENTIRE resource group, and thus everything touched by this script, run:"
echo " az group delete --name $AZURE_RESOURCE_GROUP"
echo

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

@ -0,0 +1,76 @@
#!/bin/bash
[[ "$AZURE_STORAGE_CONN_STRING" =~ ';AccountName='[^\;]*';' ]] && \
echo "Using AZURE_STORAGE_CONN_STRING with account "${BASH_REMATCH}
set -euo pipefail
# ------------------------------------------------------------------------------
# This script is meant to be used in automated testing. The output is
# ugly (interleaved) because it creates concurrent child processes.
#
# It should exit cleanly after the test is complete.
#
# This is often invoked within Docker:
# docker run -it --rm --env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" ambrosia-hello ./run_helloworld_locally.sh
#
# ------------------------------------------------------------------------------
cd `dirname $0`
if ! [ ${OFFSET:+defined} ]; then
OFFSET=0
fi
PORT1=1000
PORT2=1001
PORT3=2000
PORT4=2001
CRAPORT1=1500
CRAPORT2=2500
# ME=`whoami`
ME=rrnewton
CLIENTNAME=${ME}client${OFFSET}
SERVERNAME=${ME}server${OFFSET}
echo
echo "--------------------------------------------------------------------------------"
echo "HelloWorld with 2 instances all in this machine/container"
echo " Instance: names $CLIENTNAME, $SERVERNAME"
echo "--------------------------------------------------------------------------------"
echo
# Clear logs for this demonstration.
rm -rf ./ambrosia_logs/
echo "Running with AMBROSIA binaries from: "$(dirname `which runAmbrosiaService.sh`)
./run_helloworld_server.sh &
set +x
pid_server=$!
echo "Server launched as PID ${pid_server}. Waiting a bit."
sleep 12
if ! kill -0 $pid_server 2>/dev/null ; then
echo
echo " !!! Server already died! Not launching Client. !!!"
echo
exit 1
fi
echo
echo "Launching Client1 now:"
./run_helloworld_client.sh
echo
echo "Client finished, shutting down server in 5 seconds:"
sleep 5
kill $pid_server
wait
echo "Everything shut down. All background processes done."
echo "Finally, attempt a cleanup of our table metadata:"
set -x
UnsafeDeregisterInstance $CLIENTNAME || true
UnsafeDeregisterInstance $SERVERNAME || true
rm *-coord.*.log
set +x
echo "HelloWorld all done."

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

@ -0,0 +1,42 @@
#!/bin/bash
[[ "$AZURE_STORAGE_CONN_STRING" =~ ';AccountName='[^\;]*';' ]] && \
echo "Using AZURE_STORAGE_CONN_STRING with account "${BASH_REMATCH}
set -euo pipefail
cd `dirname $0`
PORT1=1000
PORT2=1001
CRAPORT1=1500
ME=`whoami | sed 's/[^a-zA-Z0-9]//g'`
CLIENTNAME=${ME}client
SERVERNAME=${ME}server
if ! which Ambrosia 2> /dev/null; then
echo "'Ambrosia' not found."
echo "You need Ambrosia on your PATH. Please download an AMBROSIA binary distribution."
exit 1
fi
if ! [ -e Client1/publish/Client1.dll ]; then
echo "Build products don't exist in ./Client1/publish."
echo "Did you run ./build_dotnetcore.sh yet?"
exit 1
fi
echo
echo "HelloWorld Client Starting, name $CLIENTNAME"
echo
set -x
Ambrosia RegisterInstance -i $CLIENTNAME --rp $PORT1 --sp $PORT2 -l "./ambrosia_logs/"
set +x
clog=`mktemp client-coord.XXXX.log`
set -x
AMBROSIA_INSTANCE_NAME=$CLIENTNAME AMBROSIA_IMMORTALCOORDINATOR_PORT=$CRAPORT1 \
COORDTAG=CoordCli AMBROSIA_IMMORTALCOORDINATOR_LOG=$clog \
runAmbrosiaService.sh dotnet Client1/publish/Client1.dll $CLIENTNAME $SERVERNAME
set +x
echo "HelloWorld Client finished."

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

@ -0,0 +1,39 @@
#!/bin/bash
[[ "$AZURE_STORAGE_CONN_STRING" =~ ';AccountName='[^\;]*';' ]] && \
echo "Using AZURE_STORAGE_CONN_STRING with account "${BASH_REMATCH}
set -euo pipefail
cd `dirname $0`
PORT3=2000
PORT4=2001
CRAPORT2=2500
ME=`whoami | sed 's/[^a-zA-Z0-9]//g'`
SERVERNAME=${ME}server
if ! which Ambrosia 2> /dev/null; then
echo "'Ambrosia' not found."
echo "You need Ambrosia on your PATH. Please download an AMBROSIA binary distribution."
exit 1
fi
if ! [ -e Client1/publish/Client1.dll ]; then
echo "Build products don't exist in ./Client1/publish."
echo "Did you run ./build_dotnetcore.sh yet?"
exit 1
fi
echo
echo "HelloWorld Server Starting, name $SERVERNAME"
echo
set -x
Ambrosia RegisterInstance -i $SERVERNAME --rp $PORT3 --sp $PORT4 -l "./ambrosia_logs/"
set +x
slog=`mktemp server-coord.XXXX.log`
set -x
AMBROSIA_INSTANCE_NAME=$SERVERNAME AMBROSIA_IMMORTALCOORDINATOR_PORT=$CRAPORT2 \
COORDTAG=CoordServ AMBROSIA_IMMORTALCOORDINATOR_LOG=$slog \
runAmbrosiaService.sh dotnet Server/publish/Server.dll $SERVERNAME
set +x

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

@ -5,7 +5,7 @@ echo
echo "Launching docker image then sleeping:"
rm -f cont.id
docker run -t --rm --cidfile cont.id \
--env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" ambrosia-perftest \
--env AZURE_STORAGE_CONN_STRING="$AZURE_STORAGE_CONN_STRING" ambrosia/ambrosia-perftest \
./run_PTI_in_tmux.sh &
TIME=25

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

@ -76,7 +76,7 @@ case $PTI_MODE in
set -x
$DOCKER run --rm ${OPTS} \
ambrosia-perftest ./run_small_PTI_and_shutdown.sh $INSTPREF
ambrosia/ambrosia-perftest ./run_small_PTI_and_shutdown.sh $INSTPREF
set +x
;;

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

@ -133,7 +133,7 @@ function tail_tagged() {
# Side effect: runs a tail proycess in the background
function start_immortal_coordinator() {
echo " $TAG Launching coordinator with: ImmortalCoordinator" $*
if ! which ImmortalCoordinator; then
if ! which ImmortalCoordinator 2> /dev/null; then
echo " ERROR $TAG - ImmortalCoordinator not found on path!"
exit 1
fi
@ -150,28 +150,36 @@ function start_immortal_coordinator() {
fi
echo " $TAG Redirecting output to: $COORDLOG"
# OPTION (1): Bound logs, but complicated.
# ----------------------------------------
if which rotatelogs >/dev/null ; then
# Bound the total amount of output used by the ImmortalCoordinator log:
ImmortalCoordinator $* 2>&1 | rotatelogs -f -t "$COORDLOG" 10M &
coord_pid=$!
if [[ ${AMBROSIA_SILENT_COORDINATOR:+defined} ]]; then
# OPTION (1): No output from Coordinator to stdout/stderr:
ImmortalCoordinator $* 2>&1 > "$COORDLOG" &
coord_pid=$!
elif [ ${RUNAMBROSIA_USE_TAIL:+defined} ]; then
# OPTION (2): Bound logs, but complicated (and tends to leave stray tail processes)
# ---------------------------------------------------------------------------------
if which rotatelogs 2> /dev/null ; then
# Bound the total amount of output used by the ImmortalCoordinator log:
ImmortalCoordinator $* 2>&1 | rotatelogs -f -t "$COORDLOG" 10M &
coord_pid=$!
else
echo " ! WARNING $TAG: rotatelogs not available, NOT bounding size of $COORDLOG"
ImmortalCoordinator $* >>"$COORDLOG" 2>&1 &
coord_pid=$!
fi
if ! [[ ${AMBROSIA_SILENT_COORDINATOR:+defined} ]]; then
tail_tagged "$COORDTAG" "$COORDLOG"
fi
else
echo " ! WARNING $TAG: rotatelogs not available, NOT bounding size of $COORDLOG"
ImmortalCoordinator $* >>"$COORDLOG" 2>&1 &
coord_pid=$!
# OPTION (3) Just use tee. Don't bound coordinator log on disk.
# -------------------------------------------------------------
ImmortalCoordinator $* 2>&1 | tee "$COORDLOG" | tag_stdin "$COORDTAG" &
coord_pid=$!
fi
if ! [[ ${AMBROSIA_SILENT_COORDINATOR:+defined} ]]; then
tail_tagged "$COORDTAG" "$COORDLOG"
fi
# ----------------------------------------
# OPTION (2) Don't bound coordinator log on disk. Keep it simple:
# ImmortalCoordinator $* 2>&1 | tee "$COORDLOG" &
# coord_pid=$!
while ! grep -q "Ready" "$COORDLOG" && kill -0 $coord_pid 2>/dev/null ;
do sleep 2; done
if ! kill -0 $coord_pid 2>/dev/null ;
then echo
echo "--------------- ERROR $TAG ----------------"
@ -195,7 +203,7 @@ keep_monitoring=`mktemp healthMonitorContinue.XXXXXX`
touch $keep_monitoring
function monitor_health() {
echo " $TAG Health monitor starting coord_pid=$coord_pid, app_pid=$app_pid"
echo " $TAG Health monitor starting, coord_pid=$coord_pid, app_pid=$app_pid"
while [ -f $keep_monitoring ]; do
sleep 2
if ! kill -0 $coord_pid 2>/dev/null ; then
@ -220,18 +228,18 @@ start_immortal_coordinator -i $AMBROSIA_INSTANCE_NAME -p $AMBROSIA_IMMORTALCOORD
# Step 2:
echo " $TAG Launching app process alongside coordinator:"
set -x
# Test for interactive shell:
if tty -s; then
set -x
$* < /dev/stdin &
set +x
app_pid=$!
else
set -x
$* &
set +x
app_pid=$!
fi
set +x
monitor_health &

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

@ -44,12 +44,23 @@ case $mode in
# Application 2: Hello World Sample
# ----------------------------------------
# docker --rm ambrosia-dev ./Samples/HelloWorld/build_dotnetcore.sh
# docker --rm ambrosia/ambrosia-dev ./Samples/HelloWorld/build_dotnetcore.sh
cd "$AMBROSIA_ROOT"/Samples/HelloWorld
docker build -t ambrosia-hello .
if [ ${AZURE_STORAGE_CONN_STRING:+defined} ]; then
# Expects stdin, so we pipe 'yes' to it:
docker run -it --rm --env "AZURE_STORAGE_CONN_STRING=$AZURE_STORAGE_CONN_STRING" \
ambrosia-hello bash -c 'yes|./run_helloworld_both.sh' \
|| echo "Allowed failure for now."
fi
# Application 3: NativeService
# ----------------------------------------
# docker --env AZURE_STORAGE_CONN_STRING="${AZURE_STORAGE_CONN_STRING}" --rm \
# ambrosia-nativeapp ./run_test_in_one_machine.sh
echo "Examine Docker image sizes:"
docker images
;;
@ -83,6 +94,14 @@ case $mode in
cd "$AMBROSIA_ROOT"/Clients/C
./run_hello_world.sh || echo "Allowed failure for now."
# Test Application: Hello World Sample
# ----------------------------------------
cd "$AMBROSIA_ROOT"/Samples/HelloWorld
./build_dotnetcore.sh
# Expects stdin, so we pipe 'yes' to it:
yes | ./run_helloworld_both.sh || echo "Allowed failure for now."
# Test Application: PTI (last because it's slow)
# ----------------------------------------------
cd "$AMBROSIA_ROOT"/InternalImmortals/PerformanceTestInterruptible

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

@ -11,10 +11,10 @@ set -euo pipefail
#
# Run this inside a fresh working copy.
TAG1A=ambrosia-dev
TAG1B=ambrosia
TAG2=ambrosia-perftest
TAG3=ambrosia-nativeapp
TAG1A=ambrosia/ambrosia-dev
TAG1B=ambrosia/ambrosia
TAG2=ambrosia/ambrosia-perftest
TAG3=ambrosia/ambrosia-nativeapp
if ! [[ ${DOCKER:+defined} ]]; then
DOCKER=docker
@ -37,7 +37,7 @@ fi
echo "================================================================================"
echo
$DOCKER build -t ${TAG1A} .
$DOCKER build -t ${TAG1A} .
if ! [[ ${DONT_BUILD_RELEASE_IMAGE:+defined} ]]; then
echo;echo "Building Release Image: $TAG1B"; echo
@ -72,7 +72,7 @@ if ! [[ ${DONT_BUILD_TARBALL:+defined} ]]; then
set -x
rm -rf ambrosia.tgz
TMPCONT=temp-container-name_`date '+%s'`
$DOCKER run --name $TMPCONT ambrosia-dev bash -c 'tar czf /ambrosia/ambrosia.tgz /ambrosia/bin'
$DOCKER run --name $TMPCONT $TAG1A bash -c 'tar czf /ambrosia/ambrosia.tgz /ambrosia/bin'
$DOCKER cp $TMPCONT:/ambrosia/ambrosia.tgz ambrosia.tgz
$DOCKER rm $TMPCONT
set +x