Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python-distem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
myriads-team
python-distem
Commits
1a940d09
Commit
1a940d09
authored
6 years ago
by
OLIVO Romain
Browse files
Options
Downloads
Patches
Plain Diff
Delete example.py
parent
9c67be94
No related branches found
No related tags found
No related merge requests found
Pipeline
#86377
passed with warnings
6 years ago
Stage: test
Stage: publish
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/example.py
+0
-175
0 additions, 175 deletions
tests/example.py
with
0 additions
and
175 deletions
tests/example.py
deleted
100644 → 0
+
0
−
175
View file @
9c67be94
import
requests
import
os
import
json
import
copy
from
statistics
import
mean
from
statistics
import
stdev
from
math
import
sqrt
if
__name__
==
"
__main__
"
:
# The path to the compressed filesystem image
# We can point to local file since our homedir is available from NFS
FSIMG
=
"
file:///home/rolivo/distem_img/distem-fs-jessie.tar.gz
"
# Put the physical machines that have been assigned to you
# You can get that by executing: cat $OAR_NODE_FILE | uniq
PNODES
=
[
"
econome-21.nantes.grid5000.fr
"
,
"
econome-5.nantes.grid5000.fr
"
]
# The first argument of the script is the address (in CIDR format)
# of the virtual network to set-up in our platform
# This ruby hash table describes our virtual network
vnet
=
{
'
name
'
:
'
lol
'
,
'
address
'
:
"
10.176.0.0/22
"
}
nodelist
=
[
'
node-1
'
,
'
node-2
'
]
# Read SSH keys
PRIV_KEY
=
os
.
path
.
join
(
os
.
environ
[
"
HOME
"
],
"
.ssh
"
,
"
id_rsa
"
)
PUB_KEY
=
"
%s.pub
"
%
PRIV_KEY
private_key
=
open
(
os
.
path
.
expanduser
(
PRIV_KEY
)).
read
()
public_key
=
open
(
os
.
path
.
expanduser
(
PUB_KEY
)).
read
()
sshkeys
=
{
"
public
"
:
public_key
,
"
private
"
:
private_key
}
latencies
=
[
'
0ms
'
,
'
20ms
'
,
'
40ms
'
,
'
60ms
'
]
results
=
{
'
scp
'
:
{},
'
rsync
'
:
{}
}
node1
=
{
'
name
'
:
'
node-1
'
,
'
address
'
:
[]
}
node2
=
{
'
name
'
:
'
node-2
'
,
'
address
'
:
[]
}
ifname
=
'
if0
'
iteration
=
5
def
average
(
values
,
length_values
):
sum_values
=
0.0
for
i
in
range
(
length_values
):
sum_values
+=
values
[
i
]
return
sum_values
/
length_values
def
stddev
(
values
,
iteration
):
return
sqrt
(
values
/
iteration
)
# Connect to the Distem server (on http://localhost:4567 by default)
distem
=
Distem
()
# Start by creating the virtual network
print
(
"
Network created
"
)
distem
.
vnetwork_create
(
vnet
[
'
name
'
],
vnet
[
'
address
'
])
# Creating one virtual node per physical one
# Create the first virtual node and set it to be hosted on
# the first physical machine
print
(
"
Node %s created
"
%
nodelist
[
0
])
distem
.
vnode_create
(
nodelist
[
0
],
{
'
host
'
:
PNODES
[
0
]},
sshkeys
)
# Specify the path to the compressed filesystem image
# of this virtual node
distem
.
vfilesystem_create
(
nodelist
[
0
],
{
'
image
'
:
FSIMG
})
# Create a virtual network interface and connect it to vnet
print
(
"
Interface created
"
)
distem
.
viface_create
(
nodelist
[
0
],
'
if0
'
,
{
'
vnetwork
'
:
vnet
[
'
name
'
],
'
default
'
:
'
true
'
})
# Create the first virtual node and set it to be hosted on
# the second physical machine
print
(
"
Node %s created
"
%
nodelist
[
1
])
distem
.
vnode_create
(
nodelist
[
1
],
{
'
host
'
:
PNODES
[
1
]
},
sshkeys
)
distem
.
vfilesystem_create
(
nodelist
[
1
],
{
'
image
'
:
FSIMG
})
# Create a virtual network interface and connect it to vnet
print
(
"
Interface created
"
)
distem
.
viface_create
(
nodelist
[
1
],
'
if0
'
,
{
'
vnetwork
'
:
vnet
[
'
name
'
]
}
)
# Starting the virtual nodes using the synchronous method
distem
.
vnodes_start
(
nodelist
)
print
(
"
Nodes started
"
)
# Getting the -automatically affected- address of each virtual nodes
# virtual network interfaces
node1
[
'
address
'
]
=
distem
.
viface_info
(
node1
[
'
name
'
],
ifname
)[
'
address
'
].
split
(
"
/
"
)[
0
]
node2
[
'
address
'
]
=
distem
.
viface_info
(
node2
[
'
name
'
],
ifname
)[
'
address
'
].
split
(
"
/
"
)[
0
]
# Creating the files we will use in our experimentation
distem
.
vnode_execute
(
node1
[
'
name
'
],
'
mkdir -p /tmp/src ; cd /tmp/src ;
\
for i in `seq 1 100`; do
\
dd if=/dev/zero of=$i bs=1K count=50;
\
done
'
)
# Printing the current latency
start_time
=
float
(
time
.
time
())
distem
.
vnode_execute
(
node1
[
'
name
'
],
'
hostname
'
)
print
(
"
Latency without any limitations # %s
"
%
(
str
(
time
.
time
()
-
start_time
)))
desc
=
{
'
output
'
:
{
'
latency
'
:
{
'
delay
'
:
[]
}
}
}
# Starting our experiment for each specified latencies
print
(
'
Starting tests
'
)
for
latency
in
latencies
:
sum_rsync
=
0.0
sum_scp
=
0.0
deviation_scp
=
0.0
deviation_rsync
=
0.0
print
(
"
Latency #%s
"
%
str
(
latency
))
# Update the latency description on virtual nodes
desc
[
'
output
'
][
'
latency
'
][
'
delay
'
]
=
latency
distem
.
viface_update
(
node1
[
'
name
'
],
ifname
,
desc
)
distem
.
viface_update
(
node2
[
'
name
'
],
ifname
,
desc
)
for
i
in
range
(
iteration
):
print
(
"
\t
Iteration ## %s
"
%
i
)
# Launch SCP test
# Cleaning target directory on node2
distem
.
vnode_execute
(
node2
[
'
name
'
],
'
rm -rf /tmp/dst
'
)
# Starting the copy from node1 to node2
start_time
=
round
(
time
.
time
(),
5
)
distem
.
vnode_execute
(
node1
[
'
name
'
],
"
scp -rq /tmp/src #{node2[
'
address
'
]}:/tmp/dst
"
)
values_scp
=
round
(
time
.
time
()
-
start_time
,
5
)
sum_scp
+=
values_scp
# Launch RSYNC test
# Cleaning target directory on node2
distem
.
vnode_execute
(
node2
[
'
name
'
],
'
rm -rf /tmp/dst
'
)
# Starting the copy from node1 to node2
start_time
=
time
.
time
()
distem
.
vnode_execute
(
'
node-1
'
,
"
rsync -r /tmp/src #{node2[
'
address
'
]}:/tmp/dst
"
)
values_rsync
=
round
(
time
.
time
()
-
start_time
,
5
)
sum_rsync
+=
values_rsync
deviation_scp
+=
(
values_scp
-
sum_scp
)
*
(
values_scp
-
sum_scp
)
deviation_rsync
+=
(
values_rsync
-
sum_rsync
)
*
(
values_rsync
-
sum_rsync
)
print
(
"
SCP results:
"
)
print
(
"
%s: [average=%s,standard_deviation=%s]
"
%
(
str
(
latency
),
str
(
sum_scp
/
iteration
),
stddev
(
deviation_scp
,
iteration
)))
print
(
"
RSYNC results:
"
)
print
(
"
%s: [average=%s,standard_deviation=%s]
"
%
(
str
(
latency
),
str
(
sum_rsync
/
iteration
),
stddev
(
deviation_rsync
,
iteration
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment