Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor 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
mediaserver
envsetup
Commits
af9177fb
Commit
af9177fb
authored
8 years ago
by
Florent Thiery
Browse files
Options
Downloads
Patches
Plain Diff
rewrite ntp test fixes
#20257
parent
2f8c4390
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/test_ntp.py
+38
-0
38 additions, 0 deletions
tests/test_ntp.py
tests/test_ntp.sh
+0
-14
0 additions, 14 deletions
tests/test_ntp.sh
with
38 additions
and
14 deletions
tests/test_ntp.py
0 → 100755
+
38
−
0
View file @
af9177fb
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2017, Florent Thiery
import
os
import
sys
import
subprocess
import
shlex
import
imp
# Check that ntpd is synced
print
(
'
Running ntpq -pd
'
)
ntpd_status
=
subprocess
.
getoutput
(
'
LANG=C ntpq -pd
'
)
if
not
'
remote
'
in
ntpd_status
:
print
(
'
NTP not working, ntpq -p output:
\n
%s
'
%
ntpd_status
)
sys
.
exit
(
1
)
else
:
print
(
'
System is NTP synchronized
'
)
print
(
'
Checking NTP server conforms to conf
'
)
if
os
.
path
.
isfile
(
'
../utils.py
'
):
es_utils
=
imp
.
load_source
(
'
es_utils
'
,
'
../utils.py
'
)
conf
=
es_utils
.
load_conf
()
NTP_SERVER
=
conf
.
get
(
'
NTP_SERVER1
'
)
with
open
(
'
/etc/ntp.conf
'
,
'
r
'
)
as
f
:
d
=
f
.
read
()
servers
=
list
()
for
l
in
d
.
split
(
'
\n
'
):
if
l
.
startswith
(
'
server
'
):
servers
.
append
(
l
.
split
(
'
server
'
)[
1
])
if
not
'
server %s
'
%
NTP_SERVER
in
d
:
print
(
'
Expected NTP server %s not found in /etc/ntp.conf, found %s instead
'
%
(
NTP_SERVER
,
servers
))
sys
.
exit
(
1
)
else
:
print
(
'
Expected NTP server found in configuration
'
)
else
:
print
(
'
Could not find envsetup conf file or not running from expected location
'
)
sys
.
exit
(
1
)
This diff is collapsed.
Click to expand it.
tests/test_ntp.sh
deleted
100755 → 0
+
0
−
14
View file @
2f8c4390
#!/bin/bash
# Check that the time synchronization server is reachable.
set
-e
source
/root/envsetup/conf.sh
NTP_SERVER
=
"
$NTP_SERVER1
"
if
[
"
${
NTP_SERVER
}
"
=
""
]
;
then
NTP_SERVER
=
"ntp.ubuntu.com"
fi
echo
"Testing NTP server:
${
NTP_SERVER
}
"
service ntp stop
ntpdate
-d
${
NTP_SERVER
}
>
/dev/null
service ntp restart
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