Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
acceptance-tests/acceptance-pack/src/test/resources/car_timeout.btm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
############################################################## | ||
# rules to timeout the car after invoking the services | ||
# | ||
############################################################### | ||
RULE set the saga compensable timeout to 5s | ||
INTERFACE org.apache.servicecomb.saga.omega.transaction.annotations.Compensable | ||
METHOD timeout | ||
AT EXIT | ||
IF TRUE | ||
DO RETURN 5 | ||
ENDRULE | ||
|
||
RULE sleep when postCarBooking until timeout happens | ||
CLASS org.apache.servicecomb.saga.demo.pack.car.CarBookingService | ||
METHOD postCarBooking | ||
AT ENTRY | ||
IF TRUE | ||
DO debug("delay 10s until the car booking timeout"), | ||
Thread.sleep(10000) | ||
ENDRULE |
35 changes: 35 additions & 0 deletions
35
acceptance-tests/acceptance-pack/src/test/resources/hotel_timeout.btm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
############################################################## | ||
# rules to timeout the car after invoking the services | ||
# | ||
############################################################### | ||
RULE set the saga compensable timeout to 2s | ||
INTERFACE org.apache.servicecomb.saga.omega.transaction.annotations.Compensable | ||
METHOD timeout | ||
AT EXIT | ||
IF TRUE | ||
DO RETURN 2 | ||
ENDRULE | ||
|
||
RULE sleep when postHotelBooking until timeout happens | ||
CLASS org.apache.servicecomb.saga.demo.pack.hotel.HotelBookingService | ||
METHOD postHotelBooking | ||
AT ENTRY | ||
IF TRUE | ||
DO debug("delay 10s until the car booking timeout"), | ||
Thread.sleep(4000) | ||
ENDRULE |
39 changes: 39 additions & 0 deletions
39
acceptance-tests/acceptance-pack/src/test/resources/pack_car_timeout_scenario.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
Feature: Alpha records transaction events | ||
|
||
Scenario: Car transaction timeout and will be compensated | ||
Given Car Service is up and running | ||
And Hotel Service is up and running | ||
And Booking Service is up and running | ||
And Alpha is up and running | ||
|
||
Given Install the byteman script car_timeout.btm to Car Service | ||
|
||
When User Jason requests to book 1 cars and 1 rooms | ||
|
||
Then Alpha records the following events | ||
| serviceName | type | | ||
| pack-booking | SagaStartedEvent | | ||
| pack-car | TxStartedEvent | | ||
| pack-car | TxAbortedEvent | | ||
| pack-car | TxCompensatedEvent | | ||
| pack-car | SagaEndedEvent | | ||
| pack-car | TxEndedEvent | | ||
|
||
Then Car Service contains the following booking orders | ||
| name | amount | confirmed | cancelled | | ||
| Jason | 1 | true | false | |
47 changes: 47 additions & 0 deletions
47
acceptance-tests/acceptance-pack/src/test/resources/pack_hotel_timeout_scenario.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
Feature: Alpha records transaction events | ||
|
||
Scenario: Hotel transaction timeout and will be compensated | ||
Given Car Service is up and running | ||
And Hotel Service is up and running | ||
And Booking Service is up and running | ||
And Alpha is up and running | ||
|
||
Given Install the byteman script hotel_timeout.btm to Hotel Service | ||
|
||
When User Jason requests to book 1 cars and 1 rooms | ||
|
||
Then Alpha records the following events | ||
| serviceName | type | | ||
| pack-booking | SagaStartedEvent | | ||
| pack-car | TxStartedEvent | | ||
| pack-car | TxEndedEvent | | ||
| pack-hotel | TxStartedEvent | | ||
| pack-hotel | TxAbortedEvent | | ||
| pack-car | TxCompensatedEvent | | ||
| pack-hotel | TxCompensatedEvent | | ||
| pack-hotel | SagaEndedEvent | | ||
| pack-hotel | TxEndedEvent | | ||
| pack-booking | SagaEndedEvent | | ||
|
||
Then Car Service contains the following booking orders | ||
| name | amount | confirmed | cancelled | | ||
| Jason | 1 | false | true | | ||
|
||
And Hotel Service contains the following booking orders | ||
| name | amount | confirmed | cancelled | | ||
| Jason | 1 | true | false | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters