Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CDEK Development
cdek-warehouse
Commits
e15114f6
Commit
e15114f6
authored
8 years ago
by
d.maklakov
Browse files
Options
Download
Email Patches
Plain Diff
Add test with thousand cargo places travelled through three instances.
parent
5e621608
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
warehouse-common/warehouse-api/src/main/java/com/cdek/transport/model/cargoplace/sync/ConsolidationUuidsTO.java
+3
-2
...transport/model/cargoplace/sync/ConsolidationUuidsTO.java
warehouse-common/warehouse-web/src/main/java/ru/cdek/warehouse/web/controller/TestController.java
+44
-0
...java/ru/cdek/warehouse/web/controller/TestController.java
warehouse-common/warehouse-web/src/test/java/ru/cdek/warehouse/web/sync/CargoPlaceSyncDocumentsTest.java
+43
-7
.../cdek/warehouse/web/sync/CargoPlaceSyncDocumentsTest.java
warehouse-common/warehouse-web/src/test/java/ru/cdek/warehouse/web/sync/support/RestCargoPlaceCommandClient.java
+49
-2
...rehouse/web/sync/support/RestCargoPlaceCommandClient.java
warehouse-common/warehouse-web/src/test/resources/entries/cleaning.xml
+4
-0
...mon/warehouse-web/src/test/resources/entries/cleaning.xml
warehouse-common/warehouse-web/src/test/resources/entries/sync-shipment-base-test.xml
+2001
-1
...eb/src/test/resources/entries/sync-shipment-base-test.xml
with
2144 additions
and
12 deletions
+2144
-12
warehouse-common/warehouse-api/src/main/java/com/cdek/transport/model/cargoplace/sync/ConsolidationUuidsTO.java
View file @
e15114f6
package
com.cdek.transport.model.cargoplace.sync
;
import
java.
util.List
;
import
java.
io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Класс для хранения и передачи uuid'ов грузомест, связанных с консолидированным грузоместом
*/
public
class
ConsolidationUuidsTO
{
public
class
ConsolidationUuidsTO
implements
Serializable
{
/**
* uuid консолидированного грузоместа
*/
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-web/src/main/java/ru/cdek/warehouse/web/controller/TestController.java
View file @
e15114f6
...
...
@@ -7,6 +7,9 @@ import org.springframework.stereotype.Controller;
import
org.springframework.web.bind.annotation.*
;
import
ru.cdek.warehouse.web.test.CargoPlaceCommandExecutor
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Контроллер для выполнения запросов в тестах
*/
...
...
@@ -33,6 +36,47 @@ public class TestController extends BaseController {
cargoPlaceCommandExecutor
.
accept
(
consolidationUuidsTO
);
}
@RequestMapping
(
value
=
"/cargoplace/multiple_ship/{count}/{waybillUuid}/{waybillItemUuid}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
List
<
ConsolidationUuidsTO
>
multipleShip
(
@PathVariable
(
"count"
)
Integer
count
,
@PathVariable
(
"waybillUuid"
)
String
waybillUuid
,
@PathVariable
(
"waybillItemUuid"
)
String
waybillItemUuid
)
{
List
<
ConsolidationUuidsTO
>
result
=
new
ArrayList
<>(
count
);
for
(
int
index
=
0
;
index
<
count
;
++
index
)
{
result
.
add
(
cargoPlaceCommandExecutor
.
ship
(
waybillUuid
,
generateUuid
(
waybillItemUuid
,
index
)));
}
return
result
;
}
@RequestMapping
(
value
=
"/cargoplace/multiple_transit"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
List
<
ConsolidationUuidsTO
>
transit
(
@RequestBody
List
<
ConsolidationUuidsTO
>
consolidationUuidsTOs
)
{
List
<
ConsolidationUuidsTO
>
result
=
new
ArrayList
<>(
consolidationUuidsTOs
.
size
());
for
(
ConsolidationUuidsTO
uuidsTO:
consolidationUuidsTOs
)
{
result
.
add
(
cargoPlaceCommandExecutor
.
transit
(
uuidsTO
));
}
return
result
;
}
@RequestMapping
(
value
=
"/cargoplace/multiple_accept"
,
method
=
RequestMethod
.
POST
)
@ResponseStatus
(
value
=
HttpStatus
.
OK
)
public
void
accept
(
@RequestBody
List
<
ConsolidationUuidsTO
>
consolidationUuidsTOs
)
{
for
(
ConsolidationUuidsTO
uuidsTO:
consolidationUuidsTOs
)
{
cargoPlaceCommandExecutor
.
accept
(
uuidsTO
);
}
}
private
static
String
generateUuid
(
String
baseUuid
,
int
addIndex
)
{
String
[]
parts
=
baseUuid
.
split
(
"-"
);
int
lastIndex
=
parts
.
length
-
1
;
String
modifiedPart
=
parts
[
lastIndex
];
Long
longPresentation
=
Long
.
parseLong
(
modifiedPart
,
16
);
longPresentation
+=
addIndex
;
modifiedPart
=
Long
.
toHexString
(
longPresentation
);
parts
[
lastIndex
]
=
modifiedPart
;
return
String
.
join
(
"-"
,
parts
);
}
@Required
public
void
setCargoPlaceCommandExecutor
(
CargoPlaceCommandExecutor
cargoPlaceCommandExecutor
)
{
this
.
cargoPlaceCommandExecutor
=
cargoPlaceCommandExecutor
;
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-web/src/test/java/ru/cdek/warehouse/web/sync/CargoPlaceSyncDocumentsTest.java
View file @
e15114f6
package
ru.cdek.warehouse.web.sync
;
import
com.cdek.transport.model.cargoplace.sync.ConsolidationUuidsTO
;
import
com.github.springtestdbunit.DbUnitTestExecutionListener
;
import
com.github.springtestdbunit.annotation.DatabaseSetup
;
import
com.github.springtestdbunit.annotation.DatabaseTearDown
;
import
com.github.springtestdbunit.annotation.DbUnitConfiguration
;
...
...
@@ -7,7 +9,8 @@ import org.flywaydb.test.junit.FlywayTestExecutionListener;
import
org.junit.Ignore
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
com.github.springtestdbunit.DbUnitTestExecutionListener
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.annotation.DirtiesContext
;
import
org.springframework.test.context.ContextConfiguration
;
...
...
@@ -16,16 +19,14 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import
org.springframework.test.context.support.DependencyInjectionTestExecutionListener
;
import
org.springframework.test.context.support.DirtiesContextTestExecutionListener
;
import
org.springframework.test.context.transaction.TransactionalTestExecutionListener
;
import
ru.cdek.warehouse.web.sync.support.WebServerWrapper
;
import
ru.cdek.warehouse.web.sync.support.RestCargoPlaceCommandClient
;
import
com
.cdek.
transport.model.cargoplace.sync.ConsolidationUuidsTO
;
import
ru
.cdek.
warehouse.web.sync.support.WebServerWrapper
;
import
java.util.List
;
import
java.util.Arrays
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
static
org
.
springframework
.
test
.
annotation
.
DirtiesContext
.
ClassMode
.
AFTER_CLASS
;
/**
...
...
@@ -55,6 +56,7 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER
@DatabaseTearDown
(
connection
=
"aux2DatabaseConnection"
,
value
=
"/entries/cleaning.xml"
)
@DirtiesContext
(
classMode
=
AFTER_CLASS
)
public
class
CargoPlaceSyncDocumentsTest
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
CargoPlaceSyncDocumentsTest
.
class
);
private
static
final
String
AUX0_URL
=
"http://localhost:7072"
;
private
static
final
String
AUX1_URL
=
"http://localhost:7074"
;
...
...
@@ -67,7 +69,9 @@ public class CargoPlaceSyncDocumentsTest {
private
static
final
Integer
CENTRAL_SERVER
=
3
;
private
static
String
WAYBILL_UUID
=
"02528380-819d-4c0e-8f78-017b1caa1717"
;
private
static
String
WAYBILL_ITEM_UUID
=
"baca8bda-6bd1-41b7-866c-01c5a49204ee"
;
private
static
String
WAYBILL_ITEM_UUID
=
"baca8bda-6bd1-41b7-866c-11c5a49204ee"
;
private
static
final
Integer
HIGH_LOAD_TEST_CARGO_PLACES_COUNT
=
1000
;
@Autowired
private
RestCargoPlaceCommandClient
cargoPlaceCommandClient
;
...
...
@@ -103,6 +107,38 @@ public class CargoPlaceSyncDocumentsTest {
stopWebServers
(
servers
);
}
@Test
@Ignore
public
void
testPhase15HighLoad_Ok
()
throws
InterruptedException
{
List
<
WebServerWrapper
>
servers
=
getWebServers
();
assertTrue
(
servers
.
get
(
CENTRAL_SERVER
).
start
());
assertTrue
(
servers
.
get
(
AUX0_SERVER
).
start
());
assertTrue
(
servers
.
get
(
AUX1_SERVER
).
start
());
assertTrue
(
servers
.
get
(
AUX2_SERVER
).
start
());
long
startTime
=
System
.
currentTimeMillis
();
List
<
ConsolidationUuidsTO
>
consolidationUuids
=
cargoPlaceCommandClient
.
multipleShip
(
AUX0_URL
,
HIGH_LOAD_TEST_CARGO_PLACES_COUNT
,
WAYBILL_UUID
,
WAYBILL_ITEM_UUID
);
waitToSyncWebServers
();
assertNotNull
(
consolidationUuids
);
assertTrue
(
consolidationUuids
.
size
()
==
HIGH_LOAD_TEST_CARGO_PLACES_COUNT
);
consolidationUuids
=
cargoPlaceCommandClient
.
multipleTransit
(
AUX1_URL
,
consolidationUuids
);
waitToSyncWebServers
();
assertNotNull
(
consolidationUuids
);
assertTrue
(
consolidationUuids
.
size
()
==
HIGH_LOAD_TEST_CARGO_PLACES_COUNT
);
assertTrue
(
cargoPlaceCommandClient
.
multipleAccept
(
AUX2_URL
,
consolidationUuids
));
waitToSyncWebServers
();
LOG
.
info
(
String
.
format
(
"Processing of %d cargo places took %d ms"
,
HIGH_LOAD_TEST_CARGO_PLACES_COUNT
,
System
.
currentTimeMillis
()
-
startTime
));
stopWebServers
(
servers
);
}
private
List
<
WebServerWrapper
>
getWebServers
()
{
WebServerWrapper
[]
servers
=
{
new
WebServerWrapper
(
".\\src\\test\\resources\\test-aux0-config.properties"
),
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-web/src/test/java/ru/cdek/warehouse/web/sync/support/RestCargoPlaceCommandClient.java
View file @
e15114f6
...
...
@@ -11,6 +11,9 @@ import org.springframework.beans.factory.annotation.Required;
import
org.springframework.util.DigestUtils
;
import
org.springframework.web.client.RestTemplate
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* Клиент удаленного запуска эмуляций действий персонала склада
*/
...
...
@@ -26,8 +29,8 @@ public class RestCargoPlaceCommandClient implements InitializingBean {
private
RestTemplateFactory
restTemplateFactory
=
new
RestTemplateFactory
();
public
void
afterPropertiesSet
()
throws
Exception
{
restTemplateFactory
.
setReadTimeout
(
6
0000
);
restTemplateFactory
.
setConnectTimeout
(
6
0000
);
restTemplateFactory
.
setReadTimeout
(
30
0000
);
restTemplateFactory
.
setConnectTimeout
(
30
0000
);
restTemplateFactory
.
setUserProvider
(
testUserProvider
);
}
...
...
@@ -45,6 +48,22 @@ public class RestCargoPlaceCommandClient implements InitializingBean {
}
}
public
List
<
ConsolidationUuidsTO
>
multipleShip
(
String
url
,
Integer
count
,
String
waybillUuid
,
String
startWaybillItemUuid
)
{
testUserProvider
.
getCurrentUser
().
token
=
generateToken
(
url
,
testUserProvider
.
getCurrentUser
());
try
{
String
path
=
createUrl
(
url
,
CARGO_PLACE_API_URL
+
"/multiple_ship/{count}/{waybillUuid}/{startWaybillItemUuid}"
);
RestTemplate
requestTemplate
=
restTemplateFactory
.
getObject
();
ConsolidationUuidsTO
[]
uuids
=
requestTemplate
.
postForObject
(
path
,
null
,
ConsolidationUuidsTO
[].
class
,
count
,
waybillUuid
,
startWaybillItemUuid
);
return
Arrays
.
asList
(
uuids
);
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"Fails to ship multiple cargo place(s)."
,
ex
);
return
null
;
}
}
public
ConsolidationUuidsTO
transit
(
String
url
,
ConsolidationUuidsTO
consolidationUuidsTO
)
{
testUserProvider
.
getCurrentUser
().
token
=
generateToken
(
url
,
testUserProvider
.
getCurrentUser
());
...
...
@@ -59,6 +78,21 @@ public class RestCargoPlaceCommandClient implements InitializingBean {
}
}
public
List
<
ConsolidationUuidsTO
>
multipleTransit
(
String
url
,
List
<
ConsolidationUuidsTO
>
consolidationUuidsTOs
)
{
testUserProvider
.
getCurrentUser
().
token
=
generateToken
(
url
,
testUserProvider
.
getCurrentUser
());
try
{
String
path
=
createUrl
(
url
,
CARGO_PLACE_API_URL
+
"/multiple_transit"
);
RestTemplate
requestTemplate
=
restTemplateFactory
.
getObject
();
ConsolidationUuidsTO
[]
uuids
=
requestTemplate
.
postForObject
(
path
,
consolidationUuidsTOs
,
ConsolidationUuidsTO
[].
class
);
return
Arrays
.
asList
(
uuids
);
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"Fails to transit multiple cargo place(s)."
,
ex
);
return
null
;
}
}
public
boolean
accept
(
String
url
,
ConsolidationUuidsTO
consolidationUuidsTO
)
{
testUserProvider
.
getCurrentUser
().
token
=
generateToken
(
url
,
testUserProvider
.
getCurrentUser
());
...
...
@@ -72,6 +106,19 @@ public class RestCargoPlaceCommandClient implements InitializingBean {
}
}
public
boolean
multipleAccept
(
String
url
,
List
<
ConsolidationUuidsTO
>
consolidationUuidsTOs
)
{
testUserProvider
.
getCurrentUser
().
token
=
generateToken
(
url
,
testUserProvider
.
getCurrentUser
());
try
{
RestTemplate
requestTemplate
=
restTemplateFactory
.
getObject
();
requestTemplate
.
postForLocation
(
createUrl
(
url
,
CARGO_PLACE_API_URL
+
"/multiple_accept"
),
consolidationUuidsTOs
);
return
true
;
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"Fails to accept multiple cargo place(s)."
,
ex
);
return
false
;
}
}
private
String
createUrl
(
String
url
,
String
path
)
{
return
url
+
'/'
+
path
;
}
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-web/src/test/resources/entries/cleaning.xml
View file @
e15114f6
...
...
@@ -25,7 +25,10 @@
<document_consolidation
/>
<document_acceptance
/>
<document_deconsolidation
/>
<document_delivery
/>
<document_return_undelivered
/>
<shipment
/>
<document_sorter_income
/>
<cargo_place
/>
<cargo_place_status
/>
...
...
@@ -34,6 +37,7 @@
<cargo_place_problem_lnk
/>
<correction_cargo_place_lnk
/>
<document_sorter_item_lnk
/>
<document_cargo_place_lnk
/>
<document_seal_lnk
/>
...
...
This diff is collapsed.
Click to expand it.
warehouse-common/warehouse-web/src/test/resources/entries/sync-shipment-base-test.xml
View file @
e15114f6
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help