Allow delete/update of rule even if in active state.
diff --git a/tests/src/common/Wsk.scala b/tests/src/common/Wsk.scala
index 5273e80..15ee8a5 100644
--- a/tests/src/common/Wsk.scala
+++ b/tests/src/common/Wsk.scala
@@ -412,7 +412,7 @@
}
/**
- * Deletes rule. Attempts to disable rule first.
+ * Deletes rule.
*
* @param name either a fully qualified name or a simple entity name
* @param expectedExitCode (optional) the expected exit code for the command
@@ -422,9 +422,6 @@
name: String,
expectedExitCode: Int = SUCCESS_EXIT)(
implicit wp: WskProps): RunResult = {
- val disable = Try { disableRule(name, expectedExitCode) }
- if (expectedExitCode != DONTCARE_EXIT)
- disable.get // throws exception
super.delete(name, expectedExitCode)
}
diff --git a/tests/src/system/basic/WskBasicTests.scala b/tests/src/system/basic/WskBasicTests.scala
index 7115d6a..9530ee7 100644
--- a/tests/src/system/basic/WskBasicTests.scala
+++ b/tests/src/system/basic/WskBasicTests.scala
@@ -607,13 +607,6 @@
rule.create(name, trigger = triggerName, action = actionName)
}
- // to validate that the rule was created enabled, we do an update and expect CONFLICT
- // (because rule updates against enabled rules must fail)
- wsk.rule.create(ruleName, trigger = triggerName, action = actionName, update = true, expectedExitCode = CONFLICT)
-
- // now, we disable the rule, so that we can perform the actual update
- wsk.rule.disableRule(ruleName);
-
// finally, we perform the update, and expect success this time
wsk.rule.create(ruleName, trigger = triggerName, action = actionName, update = true)
diff --git a/tests/src/whisk/core/controller/test/RulesApiTests.scala b/tests/src/whisk/core/controller/test/RulesApiTests.scala
index 7fba8e6..5d49268 100644
--- a/tests/src/whisk/core/controller/test/RulesApiTests.scala
+++ b/tests/src/whisk/core/controller/test/RulesApiTests.scala
@@ -189,7 +189,7 @@
}
// DEL /rules/name
- it should "reject delete rule in state active" in {
+ it should "not reject delete rule in state active" in {
implicit val tid = transid()
val rule = WhiskRule(namespace, EntityName("reject_delete_rule_active"), FullyQualifiedEntityName(namespace, aname()), afullname(namespace, "an action"))
@@ -201,10 +201,11 @@
put(entityStore, rule)
Delete(s"$collectionPath/${rule.name}") ~> sealRoute(routes(creds)) ~> check {
- status should be(Conflict)
- val response = responseAs[ErrorResponse]
- response.error should be(s"rule status is '${Status.ACTIVE}', must be '${Status.INACTIVE}' to delete")
- response.code.id should be >= 1L
+ deleteTrigger(trigger.docid)
+
+ status should be(OK)
+ val response = responseAs[WhiskRuleResponse]
+ response should be(rule.withStatus(Status.INACTIVE))
}
}
@@ -470,7 +471,7 @@
}
}
- it should "update rule updating trigger and action at once" in {
+ it should "update rule with new trigger and action at once" in {
implicit val tid = transid()
val trigger = WhiskTrigger(namespace, aname())
@@ -636,20 +637,29 @@
}
}
- it should "reject update rule in state active" in {
+ it should "not reject update rule in state active" in {
implicit val tid = transid()
val rule = WhiskRule(namespace, aname(), afullname(namespace, "a trigger"), afullname(namespace, "an action"))
val trigger = WhiskTrigger(namespace, rule.trigger.name, rules = Some {
Map(rule.fullyQualifiedName(false) -> ReducedRule(rule.action, Status.ACTIVE))
})
- val content = WhiskRulePut(publish = Some(!rule.publish))
+ val action = WhiskAction(namespace, aname(), Exec.js("??"))
+ val content = WhiskRulePut(Some(trigger.fullyQualifiedName(false)), Some(action.fullyQualifiedName(false)))
- put(entityStore, trigger)
- put(entityStore, rule)
+ put(entityStore, trigger, false)
+ put(entityStore, action)
+ put(entityStore, rule, false)
Put(s"$collectionPath/${rule.name}?overwrite=true", content) ~> sealRoute(routes(creds)) ~> check {
- status should be(Conflict)
+ val t = get(entityStore, trigger.docid, WhiskTrigger)
+ deleteTrigger(t.docid)
+ deleteRule(rule.docid)
+
+ status should be(OK)
+ t.rules.get(rule.fullyQualifiedName(false)).action should be(action.fullyQualifiedName(false))
+ val response = responseAs[WhiskRuleResponse]
+ response should be(WhiskRuleResponse(namespace, rule.name, Status.ACTIVE, trigger.fullyQualifiedName(false), action.fullyQualifiedName(false), version = SemVer().upPatch))
}
}