Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IGNITE-22091] CLI for disaster recovery: partition states #3668

Merged
merged 17 commits into from
May 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
import java.util.Set;
import org.apache.ignite.internal.Cluster;
import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
import org.apache.ignite.internal.cli.call.connect.ConnectCall;
Expand Down Expand Up @@ -145,18 +146,65 @@ protected void assertOutputIs(String expectedOutput) {
.isEqualTo(expectedOutput);
}

protected void assertOutputStartsWith(String expectedOutput) {
assertThat(sout.toString())
.as("Expected command output to start with: " + expectedOutput + " but was " + sout.toString())
.startsWith(expectedOutput);
}

protected void assertOutputContains(String expectedOutput) {
assertThat(sout.toString())
.as("Expected command output to contain: " + expectedOutput + " but was " + sout.toString())
.contains(expectedOutput);
}

protected void assertOutputContainsAnyIgnoringCase(Set<String> expectedOutput) {
CharSequence[] expectedUpperCase = expectedOutput.stream().map(String::toUpperCase).toArray(CharSequence[]::new);

assertThat(sout.toString().toUpperCase())
.as("Expected command output to contain any of, ignoring case: " + expectedOutput + " but was " + sout.toString())
.containsAnyOf(expectedUpperCase);
}

protected void assertOutputContainsAny(Set<String> expectedOutput) {

assertThat(sout.toString())
.as("Expected command output to contain any of: " + expectedOutput + " but was " + sout.toString())
.containsAnyOf( expectedOutput.toArray(CharSequence[]::new));
}

protected void assertOutputContainsAllIgnoringCase(Set<String> expectedOutput) {
CharSequence[] expectedUpperCase = expectedOutput.stream().map(String::toUpperCase).toArray(CharSequence[]::new);

assertThat(sout.toString().toUpperCase())
.as("Expected command output to contain all of, ignoring case: " + expectedOutput + " but was " + sout.toString())
.contains(expectedUpperCase);
}

protected void assertOutputContainsAll(Set<String> expectedOutput) {
assertThat(sout.toString())
.as("Expected command output to contain all of: " + expectedOutput + " but was " + sout.toString())
.contains(expectedOutput.toArray(CharSequence[]::new));
}

protected void assertOutputDoesNotContain(String expectedOutput) {
assertThat(sout.toString())
.as("Expected command output to not contain: " + expectedOutput + " but was " + sout.toString())
.doesNotContain(expectedOutput);
}

protected void assertOutputDoesNotContain(Set<String> expectedOutput) {
assertThat(sout.toString())
.as("Expected command output to not contain: " + expectedOutput + " but was " + sout.toString())
.doesNotContain(expectedOutput.toArray(CharSequence[]::new));
}

protected void assertOutputDoesNotContainIgnoreCase(Set<String> expectedOutput) {
assertThat(sout.toString())
.as("Expected command output to not contain: " + expectedOutput + " but was " + sout.toString())
.doesNotContainIgnoringCase(expectedOutput.toArray(CharSequence[]::new));
}

protected void assertOutputMatches(String regex) {
assertThat(sout.toString())
.as("Expected command output to match regex: " + regex + " but it is not: " + sout.toString())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.
*/

package org.apache.ignite.internal.cli.commands.recovery;

import java.util.List;
import org.apache.ignite.internal.cli.commands.recovery.partitions.PartitionStatesCommand;
import org.apache.ignite.internal.util.CollectionUtils;

/** Test class for {@link PartitionStatesCommand}. */
public class ItPartitionStatesCommandTest extends ItPartitionStatesTest {

@Override
protected void execute(String... args) {
String[] fullArgs = CollectionUtils.concat(List.of("recovery", "partition-states"), List.of(args)).toArray(String[]::new);

super.execute(fullArgs);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.
*/

package org.apache.ignite.internal.cli.commands.recovery;

import org.apache.ignite.internal.cli.commands.recovery.partitions.PartitionStatesReplCommand;

/** Test class for {@link PartitionStatesReplCommand}. */
public class ItPartitionStatesReplCommandTest extends ItPartitionStatesTest {

@Override
protected Class<?> getCommandClass() {
return PartitionStatesReplCommand.class;
}
}