Skip to content

Commit

Permalink
Bug fix for github issue web-platform-tests#241 in w3c/automotive
Browse files Browse the repository at this point in the history
(w3c/automotive#241)
- Fixed by adding code to ignore SubscriptionNotificationResponse/ErrorResponse
  after Unsubscibe request has been sent to VISServer.
  • Loading branch information
aShinjiroUrata committed Nov 20, 2017
1 parent 490d1b8 commit 2ad5d41
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 18 deletions.
17 changes: 13 additions & 4 deletions vehicle/viss/0180-subscribe-success.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,19 @@
} else if (phase == PH_SENT_UNSUBSCRIBE) {
t.step_func(function() {
// wait for unsubscribe response
var res = isUnsubscribeSuccessResponse(reqId, subId, msg);
assert_true(res, "True if unsubscribeSuccessResponse received.");

if (res) {
var res1 = isSubscriptionNotificationResponse(subId, msg);
if (res1) {
addLogMessage("Ignore SubscriptionNotificationResponse.");
return;
}
var res2 = isSubscriptionNotificationErrorResponse(subId, msg);
if (res2) {
addLogMessage("Ignore SubscriptionNotificationErrorResponse.");
return;
}
var res3 = isUnsubscribeSuccessResponse(reqId, subId, msg);
assert_true(res3, "True if unsubscribeSuccessResponse received.");
if (res3) {
// unsubscibe success
phase = PH_UNSUBSCRIBED;
helper_terminate_normal("unsubscribeSuccessResponse received");
Expand Down
16 changes: 13 additions & 3 deletions vehicle/viss/0190-subscribe-notification-success.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,19 @@
} else if (phase == PH_SENT_UNSUBSCRIBE) {
t.step_func(function() {
// wait for unsubscribe response
var res = isUnsubscribeSuccessResponse(reqId, subId, msg);
assert_true(res, "True if UnsubscribeSuccessResponse received.");
if (res) {
var res1 = isSubscriptionNotificationResponse(subId, msg);
if (res1) {
addLogMessage("Ignore SubscriptionNotificationResponse.");
return;
}
var res2 = isSubscriptionNotificationErrorResponse(subId, msg);
if (res2) {
addLogMessage("Ignore SubscriptionNotificationErrorResponse.");
return;
}
var res3 = isUnsubscribeSuccessResponse(reqId, subId, msg);
assert_true(res3, "True if UnsubscribeSuccessResponse received.");
if (res3) {
// unsubscibe success
phase = PH_UNSUBSCRIBED;
helper_terminate_normal("unsubscribe successed");
Expand Down
16 changes: 13 additions & 3 deletions vehicle/viss/0240-unsubscribe-success.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,20 @@
} else if (phase == PH_SENT_UNSUBSCRIBE) {
t.step_func(function() {
// wait for unsubscribe response
var res = isUnsubscribeSuccessResponse(reqId, subId, msg);
assert_true(res, "True if UnsubscribeSuccessResponse received.");
var res1 = isSubscriptionNotificationResponse(subId, msg);
if (res1) {
addLogMessage("Ignore SubscriptionNotificationResponse.");
return;
}
var res2 = isSubscriptionNotificationErrorResponse(subId, msg);
if (res2) {
addLogMessage("Ignore SubscriptionNotificationErrorResponse.");
return;
}
var res3 = isUnsubscribeSuccessResponse(reqId, subId, msg);
assert_true(res3, "True if UnsubscribeSuccessResponse received.");

if (res) {
if (res3) {
// unsubscibe success
phase = PH_UNSUBSCRIBED;
addLogMessage("Test Success: UnsubscribeSuccessResponse received");
Expand Down
26 changes: 19 additions & 7 deletions vehicle/viss/0250-unsubscribe-error.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@

<script>
var reqId = "reqid-0250";
var reqId1 = "reqid-0251";
var reqId2 = "reqid-0252";


var subId = null;

var path = SUBSCRIBE_STANDARD_PATH;
Expand Down Expand Up @@ -79,11 +83,11 @@
addLogMessage("subscribeSuccessResponse received. subId = " + msg.subscriptionId);
subId = msg.subscriptionId

// Test successed. Send unsubscribe
// Test successed. Send *INVALID* unsubscribe request
addLogMessage("Send unsubscribe request with *INVALID* subId = " + invalidSubId);
var unsub_req ='{"action":"unsubscribe"'
+' ,"subscriptionId":"'+invalidSubId+'"'
+' ,"requestId":"'+reqId+'"'
+' ,"requestId":"'+reqId1+'"'
+'}';
addLogMessage("unsub req: json=" + unsub_req);
vehicle.send( unsub_req );
Expand All @@ -96,16 +100,24 @@
} else if (phase == PH_SENT_UNSUBSCRIBE) {
t.step_func(function() {
// wait for unsubscribe response
var res = isUnsubscribeErrorResponse(reqId, invalidSubId, msg);

if (res) {
assert_true(res, "True if unsubscribeErrorResponse received.");
if (isSubscriptionNotificationResponse(subId, msg)) {
addLogMessage("Ignore SubscriptionNotificationResponse.");
return;
}
if (isSubscriptionNotificationErrorResponse(subId, msg)) {
addLogMessage("Ignore SubscriptionNotificationErrorResponse.");
return;
}
if (isUnsubscribeErrorResponse(reqId1, invalidSubId, msg)) {
phase = PH_UNSUBSCRIBED;
addLogMessage("<br>Test Success: UnsubscribeErrorResponse received");
helper_terminate_success("UnsubscribeErrorResponse received");
} else {
} else if (isUnsubscribeSuccessResponse(reqId1, invalidSubId, msg)) {
phase = PH_UNSUBSCRIBED;
addLogMessage("<br>Test Failure: UnsubscribeSuccessResponse received");
helper_terminate_failure("UnsubscribeSuccessResponse received");
} else {
helper_terminate_failure("Unknown error.");
}
})();
} else if (phase == PH_UNSUBSCRIBED) {
Expand Down
24 changes: 23 additions & 1 deletion vehicle/viss/0260-unsubscribeall-success.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@
var PH_UNSUBSCRIBED = 4;
var PH_END = 5;

// Wait time to confirm SubscriptionNotification will be received.
var TIME_CONFIRM_SUB_NOTIF = 1000;
// Time to wait for all of remaining SubscriptionNotification will be received.
var TIME_WAIT_SUB_NOTIF_END = 500;
// Time to confirm all the subscription has been really unsubscribed.
// (If no more SubscriptionNotification comes, regard as unsubscribeAll succeeded.)
var TIME_CONFIRM_UNSUBSCRIBED = 1000;

var phase = PH_START;
Expand Down Expand Up @@ -101,6 +105,7 @@
subSuccess3 = true;
}

// If all the Subscribe requests turned out successful, go to next phase
if (subSuccess1 && subSuccess2 && subSuccess3) {
phase = PH_SENT_UNSUBSCRIBE;

Expand All @@ -127,6 +132,19 @@
} else if (phase == PH_SENT_UNSUBSCRIBE) {
t.step_func(function() {

// Ignore SubscriptionNotificationResponse/ErrorResponse
// comming before UbsubscribeAll response reached.
var res1 = isSubscriptionNotificationResponse(subId, msg);
if (res1) {
addLogMessage("Ignore SubscriptionNotificationResponse.");
return;
}
var res2 = isSubscriptionNotificationErrorResponse(subId, msg);
if (res2) {
addLogMessage("Ignore SubscriptionNotificationErrorResponse.");
return;
}

if (isUnsubscribeAllSuccessResponse(reqId_unsubAll, msg)) {
addLogMessage( "UnsubscribeSuccess response received." );
// unsubscibe success
Expand Down Expand Up @@ -168,7 +186,9 @@
var bNotifError = isSubscriptionNotificationErrorResponse( "", msg);

if (bNotifSuccess || bNotifError) {
// subscriptionNotification arrived. unsubscribeAll was not succeeded
// Even after received UnsubscribeAllSuccessResponse received,
// subscriptionNotificationResponse/ErrorResponse received.
// Judge this as unsubscribeAll did not work effectively.
bNothingHasCome = false;
addLogMessage( "Some subscriptionNotification message reached event after unsubscribeAll done." );
helper_terminate_failure("unsubscribeAll failed");
Expand All @@ -177,6 +197,8 @@
})();
}
}

// Send Subscribe requests
var sub_req_1 = '{"action":"subscribe","path":"'+ path1 +'" ,"requestId":"'+reqId1+'"}';
addLogMessage("subscribe req1: json="+ sub_req_1);
vehicle.send( sub_req_1 );
Expand Down

0 comments on commit 2ad5d41

Please sign in to comment.