This commit is contained in:
Clebert Suconic 2020-08-20 11:13:19 -04:00
commit 316618e845
2 changed files with 19 additions and 0 deletions

View File

@ -37,6 +37,22 @@ import org.junit.Assert;
import org.junit.Assume;
import org.junit.Test;
/**
* This utility class will use sudo commands to start "fake" network cards on a given address.
* It's used on tests that need to emmulate network outages and split brains.
*
* If you write a new test using this class, please make special care on undoing the config,
* especially in case of failures.
*
* Usually the class {@link NetUtilResource} is pretty accurate on undoing this, but you also need to *test your test* well.
*
* You need special sudo authorizations on your system to let this class work:
*
* Add the following at the end of your /etc/sudoers (use the sudo visudo command)");
* # ------------------------------------------------------- ");
* yourUserName ALL = NOPASSWD: /sbin/ifconfig");
* # ------------------------------------------------------- ");
* */
public class NetUtil {
public static boolean checkIP(String ip) throws Exception {

View File

@ -19,6 +19,9 @@ package org.apache.activemq.artemis.utils.network;
import org.junit.rules.ExternalResource;
/**
* Just a rule where you can use to automate cleanup on NetUtil.
* */
public class NetUtilResource extends ExternalResource {
@Override