mirror of
https://github.com/ctripcorp/zeus.git
synced 2024-11-10 17:13:46 +08:00
test filter conf
This commit is contained in:
parent
e28d27e989
commit
36bd1b1de2
1 changed files with 22 additions and 0 deletions
|
@ -9,7 +9,9 @@ import com.ctrip.zeus.nginx.entity.Upstreams;
|
|||
import com.ctrip.zeus.nginx.entity.Vhosts;
|
||||
import com.ctrip.zeus.nginx.transform.DefaultJsonParser;
|
||||
import com.ctrip.zeus.service.build.BuildService;
|
||||
import com.ctrip.zeus.service.build.NginxConfService;
|
||||
import com.ctrip.zeus.support.GenericSerializer;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -45,9 +47,13 @@ public class MultiGvsAtSameSlbTest extends AbstractServerTest {
|
|||
private BuildInfoDao buildInfoDao;
|
||||
@Resource
|
||||
private BuildService buildService;
|
||||
@Resource
|
||||
private NginxConfService nginxConfService;
|
||||
|
||||
private static boolean inited = false;
|
||||
@Before
|
||||
public void setCurrentVersion() throws DalException {
|
||||
if (inited) return;
|
||||
buildInfoDao.insert(new BuildInfoDo().setSlbId(1L).setPendingTicket(2).setCurrentTicket(1));
|
||||
nginxConfDao.insert(new NginxConfDo().setSlbId(1L).setVersion(1).setContent("nginx.conf"));
|
||||
|
||||
|
@ -69,6 +75,7 @@ public class MultiGvsAtSameSlbTest extends AbstractServerTest {
|
|||
currentConf.getUpstreams().addConfFile(new ConfFile().setName("6").setContent("upstream_6"));
|
||||
|
||||
nginxConfSlbDao.insert(new NginxConfSlbDo().setSlbId(1L).setVersion(1).setContent(GenericSerializer.writeJson(currentConf)));
|
||||
inited = true;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -154,6 +161,21 @@ public class MultiGvsAtSameSlbTest extends AbstractServerTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterUpstreamsAndVhosts() throws Exception {
|
||||
NginxConfEntry filteredEntry = nginxConfService.getUpstreamsAndVhosts(1L, 1L, Lists.newArrayList(1L, 2L, 3L));
|
||||
Set<String> vhostFilename = Sets.newHashSet("1", "2", "3");
|
||||
Set<String> upstreamFilename = Sets.newHashSet("1", "1_5", "2", "2_3", "3");
|
||||
for (ConfFile cf : filteredEntry.getVhosts().getFiles()) {
|
||||
Assert.assertTrue(vhostFilename.remove(cf.getName()));
|
||||
}
|
||||
for (ConfFile cf : filteredEntry.getUpstreams().getFiles()) {
|
||||
Assert.assertTrue(upstreamFilename.remove(cf.getName()));
|
||||
}
|
||||
Assert.assertTrue(vhostFilename.isEmpty());
|
||||
Assert.assertTrue(upstreamFilename.isEmpty());
|
||||
}
|
||||
|
||||
private Group generateGroup(Long groupId, Long[] vsIds) {
|
||||
Group group = new Group().setId(groupId).setName("group_" + groupId).setAppId("000000").setSsl(false)
|
||||
.setHealthCheck(new HealthCheck().setIntervals(2000).setFails(1).setPasses(1).setUri("/"))
|
||||
|
|
Loading…
Reference in a new issue