Search in sources :

Example 6 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testRolloutSingleGroupName.

/*    @Test
    public void testRolloutWithAProp() throws Exception {

        parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout prop=value");

        assertTrue(handler.hasAddress());
        assertTrue(handler.hasOperationName());
        assertFalse(handler.hasProperties());
        assertFalse(handler.endsOnAddressOperationNameSeparator());
        assertFalse(handler.endsOnPropertyListStart());
        assertFalse(handler.endsOnPropertySeparator());
        assertFalse(handler.endsOnPropertyValueSeparator());
        assertFalse(handler.endsOnNodeSeparator());
        assertFalse(handler.endsOnNodeTypeNameSeparator());
        assertTrue(handler.endsOnSeparator());
        assertTrue(handler.endsOnHeaderListStart()); // TODO this is kind of strange but ok...
        assertFalse(handler.isRequestComplete());
        assertTrue(handler.hasHeaders());

        final List<OperationRequestHeader> headers = handler.getHeaders();
        assertEquals(1, headers.size());
        final OperationRequestHeader header = headers.get(0);
        assertTrue(header instanceof RolloutPlanHeader);
        final RolloutPlanHeader rollout = (RolloutPlanHeader) header;
        assertEquals("value", rollout.getProperty("prop"));
    }

    @Test
    public void testRolloutWithTwoProps() throws Exception {

        parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout prop1=value1 prop2 = value2");

        assertTrue(handler.hasAddress());
        assertTrue(handler.hasOperationName());
        assertFalse(handler.hasProperties());
        assertFalse(handler.endsOnAddressOperationNameSeparator());
        assertFalse(handler.endsOnPropertyListStart());
        assertFalse(handler.endsOnPropertySeparator());
        assertFalse(handler.endsOnPropertyValueSeparator());
        assertFalse(handler.endsOnNodeSeparator());
        assertFalse(handler.endsOnNodeTypeNameSeparator());
        assertTrue(handler.endsOnSeparator());
        assertTrue(handler.endsOnHeaderListStart()); // TODO this is kind of strange but ok...
        assertFalse(handler.isRequestComplete());
        assertTrue(handler.hasHeaders());

        final List<OperationRequestHeader> headers = handler.getHeaders();
        assertEquals(1, headers.size());
        final OperationRequestHeader header = headers.get(0);
        assertTrue(header instanceof RolloutPlanHeader);
        final RolloutPlanHeader rollout = (RolloutPlanHeader) header;
        assertEquals("value1", rollout.getProperty("prop1"));
        assertEquals("value2", rollout.getProperty("prop2"));
    }
*/
@Test
public void testRolloutSingleGroupName() throws Exception {
    // parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout in-series = groupA}");
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout groupA}");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertTrue(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    final ModelNode node = new ModelNode();
    final ModelNode inSeries = node.get(Util.ROLLOUT_PLAN).get(Util.IN_SERIES);
    final ModelNode groupA = new ModelNode();
    groupA.get("groupA");
    inSeries.add().get(Util.SERVER_GROUP).set(groupA);
    final ModelNode headersNode = new ModelNode();
    header.addTo(ctx, headersNode);
    assertEquals(node, headersNode);
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) ModelNode(org.jboss.dmr.ModelNode) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 7 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testEndsOnGroupConcurrent.

@Test
public void testEndsOnGroupConcurrent() throws Exception {
    parse(":do{ rollout groupA( prop = v ) ^");
    assertFalse(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    final ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    assertTrue(rollout.endsOnGroupSeparator());
    assertEquals(32, rollout.getLastSeparatorIndex());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 8 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testSpaceBeforeGroupPropertiesStart.

public void testSpaceBeforeGroupPropertiesStart() throws Exception {
    parse(":do{ rollout groupA (");
    assertFalse(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    final SingleRolloutPlanGroup group = rollout.getLastGroup();
    assertNotNull(group);
    assertEquals("groupA", group.getGroupName());
    assertTrue(group.endsOnPropertyListStart());
    assertFalse(group.endsOnPropertyListEnd());
    assertFalse(group.hasProperties());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader)

Example 9 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testMix.

@Test
public void testMix() throws Exception {
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout " + "groupA(rolling-to-servers=true,max-failure-percentage=20) ^ groupB, groupC," + "groupD(rolling-to-servers=true,max-failed-servers=1) ^ groupE");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    final ModelNode node = new ModelNode();
    final ModelNode inSeries = node.get(Util.ROLLOUT_PLAN).get(Util.IN_SERIES);
    ModelNode concurrent = new ModelNode();
    ModelNode cg = concurrent.get(Util.CONCURRENT_GROUPS);
    ModelNode group = cg.get("groupA");
    group.get("rolling-to-servers").set("true");
    group.get("max-failure-percentage").set("20");
    group = cg.get("groupB");
    inSeries.add().set(concurrent);
    ModelNode sg = new ModelNode();
    group = sg.get(Util.SERVER_GROUP);
    group.get("groupC");
    inSeries.add().set(sg);
    concurrent = new ModelNode();
    cg = concurrent.get(Util.CONCURRENT_GROUPS);
    group = cg.get("groupD");
    group.get("rolling-to-servers").set("true");
    group.get("max-failed-servers").set("1");
    group = cg.get("groupE");
    inSeries.add().set(concurrent);
    final ModelNode headersNode = new ModelNode();
    header.addTo(ctx, headersNode);
    assertEquals(node, headersNode);
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) ModelNode(org.jboss.dmr.ModelNode) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Example 10 with ParsedOperationRequestHeader

use of org.jboss.as.cli.operation.ParsedOperationRequestHeader in project wildfly-core by wildfly.

the class RolloutPlanParsingTestCase method testEndsOnGroupPropertiesStart.

@Test
public void testEndsOnGroupPropertiesStart() throws Exception {
    parse("/profile=default/subsystem=threads/thread-factory=mytf:do{ rollout groupA(");
    assertTrue(handler.hasAddress());
    assertTrue(handler.hasOperationName());
    assertFalse(handler.hasProperties());
    assertFalse(handler.endsOnAddressOperationNameSeparator());
    assertFalse(handler.endsOnPropertyListStart());
    assertFalse(handler.endsOnPropertySeparator());
    assertFalse(handler.endsOnPropertyValueSeparator());
    assertFalse(handler.endsOnNodeSeparator());
    assertFalse(handler.endsOnNodeTypeNameSeparator());
    assertFalse(handler.endsOnSeparator());
    assertFalse(handler.endsOnHeaderListStart());
    assertFalse(handler.isRequestComplete());
    assertTrue(handler.hasHeaders());
    final Collection<ParsedOperationRequestHeader> headers = handler.getHeaders();
    assertEquals(1, headers.size());
    final ParsedOperationRequestHeader header = headers.iterator().next();
    assertTrue(header instanceof ParsedRolloutPlanHeader);
    ParsedRolloutPlanHeader rollout = (ParsedRolloutPlanHeader) header;
    final SingleRolloutPlanGroup group = rollout.getLastGroup();
    assertNotNull(group);
    assertEquals("groupA", group.getGroupName());
    assertTrue(group.endsOnPropertyListStart());
    assertFalse(group.endsOnPropertyListEnd());
    assertFalse(group.hasProperties());
}
Also used : ParsedOperationRequestHeader(org.jboss.as.cli.operation.ParsedOperationRequestHeader) SingleRolloutPlanGroup(org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup) ParsedRolloutPlanHeader(org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader) Test(org.junit.Test)

Aggregations

ParsedOperationRequestHeader (org.jboss.as.cli.operation.ParsedOperationRequestHeader)27 Test (org.junit.Test)22 ParsedRolloutPlanHeader (org.jboss.as.cli.operation.impl.ParsedRolloutPlanHeader)19 ModelNode (org.jboss.dmr.ModelNode)13 SingleRolloutPlanGroup (org.jboss.as.cli.operation.impl.SingleRolloutPlanGroup)7 CommandFormatException (org.jboss.as.cli.CommandFormatException)2 TerminalString (org.aesh.readline.terminal.formatting.TerminalString)1 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)1 OperationRequestAddress (org.jboss.as.cli.operation.OperationRequestAddress)1 Node (org.jboss.as.cli.operation.OperationRequestAddress.Node)1