Mercurial > stress-tester
changeset 851:ba2ddf2d553c
ProjectConfiguratorTest
author | Devel 2 |
---|---|
date | Tue, 23 Jan 2018 14:22:47 +0100 |
parents | ecc2247b5254 |
children | bd7ddb7ff81d |
files | stress-tester/src/test/java/com/passus/st/project/ProjectConfiguratorTest.java stress-tester/src/test/resources/com/passus/st/project/test_project_config.yml |
diffstat | 2 files changed, 92 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/test/java/com/passus/st/project/ProjectConfiguratorTest.java Tue Jan 23 14:22:47 2018 +0100 @@ -0,0 +1,50 @@ +package com.passus.st.project; + +import com.passus.commons.utils.ResourceUtils; +import com.passus.config.*; +import com.passus.config.validation.Errors; +import com.passus.st.client.Client; +import com.passus.st.client.http.HttpClient; +import com.passus.st.source.EventSource; +import com.passus.st.source.NcEventSource; +import com.passus.st.source.PcapSessionEventSource; +import com.passus.st.utils.ConfigurationContextConsts; +import org.testng.annotations.Test; + +import java.io.File; +import java.util.List; + +import static org.testng.AssertJUnit.assertEquals; +import static org.testng.AssertJUnit.assertFalse; +import static org.testng.AssertJUnit.assertTrue; + +public class ProjectConfiguratorTest { + + private final Errors errors = new Errors(); + + @Test + public void testConfigure() throws Exception { + File configFile = ResourceUtils.getFile("com/passus/st/project/test_project_config.yml"); + Configuration config = YamlConfigurationReader.readFromFile(configFile); + + ProjectConfigurator configurator = new ProjectConfigurator(); + ConfigurationContext context = new ConfigurationContextImpl(); + configurator.configure(config, errors, context); + assertFalse(errors.hasError()); + + Project project = (Project) context.get(ConfigurationContextConsts.PROJECT); + assertEquals("testName", project.getName()); + assertEquals(false, project.isActive()); + assertEquals("testDescription", project.getDescription()); + + List<Client> clients = (List<Client>) context.get(ConfigurationContextConsts.CLIENT_CLIENTS); + assertEquals(1, clients.size()); + assertTrue(clients.get(0) instanceof HttpClient); + + List<EventSource> sources = (List<EventSource>) context.get(ConfigurationContextConsts.EVENT_SOURCE_SOURCES); + assertEquals(2, sources.size()); + assertTrue(sources.get(0) instanceof PcapSessionEventSource); + assertTrue(sources.get(1) instanceof NcEventSource); + + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stress-tester/src/test/resources/com/passus/st/project/test_project_config.yml Tue Jan 23 14:22:47 2018 +0100 @@ -0,0 +1,42 @@ +name: testName +active: false +description: testDescription + +reporter: + active: true + address: 2.2.2.2 + port: 222222 + + +metrics: + active: true + destinations: + - type: file + fileName: /file + active: true + +emitter: + sessionMapper: "1.1.1.1:80->2.2.2.2:90" + emitters: + - type: nio + connectionTimeout: 5s + connectionAttempts: 3 + threads: 4 + collectMetrics: true + +eventSource: + sources: + - type: pcap + fileName: /test.pcap + loops: 1 + + - type: nc + fileName: /test.nc + loops: 1 + +client: + clients: + - type: http + connectPartialSession: false + collectMetrics: true + workers: 4