Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
opennsa3
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Michal Hažlinský
opennsa3
Commits
92d165bd
Commit
92d165bd
authored
6 years ago
by
Henrik Thostrup Jensen
Browse files
Options
Downloads
Patches
Plain Diff
add database check for start time < end time, and add test case for it
parent
b114ab03
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
datafiles/schema.sql
+4
-2
4 additions, 2 deletions
datafiles/schema.sql
test/test_database.py
+50
-0
50 additions, 0 deletions
test/test_database.py
with
54 additions
and
2 deletions
datafiles/schema.sql
+
4
−
2
View file @
92d165bd
...
...
@@ -46,7 +46,8 @@ CREATE TABLE service_connections (
bandwidth
integer
NOT
NULL
,
-- mbps
parameter
parameter
[],
security_attributes
security_attribute
[],
connection_trace
text
[]
connection_trace
text
[],
CHECK
(
start_time
<
end_time
)
);
-- internal references to connections that are part of a service connection
...
...
@@ -98,7 +99,8 @@ CREATE TABLE generic_backend_connections (
directionality
directionality
NOT
NULL
,
bandwidth
integer
NOT
NULL
,
-- mbps
parameter
parameter
[],
allocated
boolean
NOT
NULL
-- indicated if the resources are actually allocated
allocated
boolean
NOT
NULL
,
-- indicated if the resources are actually allocated
CHECK
(
start_time
<
end_time
)
);
...
...
This diff is collapsed.
Click to expand it.
test/test_database.py
0 → 100644
+
50
−
0
View file @
92d165bd
import
datetime
import
psycopg2
from
twisted.internet
import
defer
from
twisted.trial
import
unittest
from
opennsa
import
state
from
opennsa.backends.common
import
genericbackend
from
.
import
db
class
DatabaseTest
(
unittest
.
TestCase
):
def
setUp
(
self
):
db
.
setupDatabase
()
@defer.inlineCallbacks
def
testReverseStartEndTimeConstraint
(
self
):
now
=
datetime
.
datetime
.
utcnow
()
start_time
=
now
-
datetime
.
timedelta
(
seconds
=
10
)
end_time
=
now
-
datetime
.
timedelta
(
seconds
=
1000
)
conn
=
genericbackend
.
GenericBackendConnections
(
connection_id
=
'
conn-123
'
,
revision
=
0
,
global_reservation_id
=
'
gid-123
'
,
description
=
'
test
'
,
requester_nsa
=
'
req-nsa
'
,
reserve_time
=
now
,
reservation_state
=
state
.
RESERVE_START
,
provision_state
=
state
.
RELEASED
,
lifecycle_state
=
state
.
CREATED
,
data_plane_active
=
False
,
source_network
=
'
src-net
'
,
source_port
=
'
src-port
'
,
source_label
=
None
,
dest_network
=
'
dst-net
'
,
dest_port
=
'
dst-port
'
,
dest_label
=
None
,
start_time
=
start_time
,
end_time
=
end_time
,
symmetrical
=
False
,
directionality
=
'
Bidirectional
'
,
bandwidth
=
200
,
allocated
=
False
)
try
:
yield
conn
.
save
()
self
.
fail
(
'
Should have gotten integrity error from database
'
)
except
psycopg2
.
IntegrityError
as
e
:
pass
# intended
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