2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.global_tests.logging;
23 import static org.junit.Assert.*;
26 import java.io.IOException;
29 import org.jboss.arquillian.container.test.api.Deployment;
30 import org.jboss.arquillian.container.test.api.OperateOnDeployment;
31 import org.jboss.arquillian.container.test.api.RunAsClient;
32 import org.jboss.arquillian.container.test.api.Testable;
33 import org.jboss.arquillian.junit.Arquillian;
34 import org.jboss.shrinkwrap.api.Archive;
35 import org.jboss.shrinkwrap.api.ShrinkWrap;
36 import org.jboss.shrinkwrap.api.spec.JavaArchive;
37 import org.jboss.shrinkwrap.api.spec.WebArchive;
38 import org.junit.After;
39 import org.junit.Before;
40 import org.junit.BeforeClass;
41 import org.junit.Test;
42 import org.junit.runner.RunWith;
44 import org.openecomp.mso.filesearching.LogFileSearching;
45 import org.openecomp.mso.global_tests.ArquillianPackagerForITCases;
47 @RunWith(Arquillian.class)
48 public class LogsCheckerITCase {
52 public static void waitBeforeStart() throws InterruptedException {
53 System.out.println("Executing " + LogsCheckerITCase.class.getName());
57 @Deployment(name = "log-check", testable = true)
58 public static Archive<?> createAsdcControllerWarDeployment() throws Exception {
59 // Any war could be used here, we just take that one randomly
60 // Be careful some WAR does not work when being injected in JBOSS, probably due to Servlet conflict
61 System.out.println("Deploying ASDC Controller WAR for log checker");
62 WebArchive warArchive = (WebArchive) ArquillianPackagerForITCases.createPackageFromExistingOne("../../asdc-controller/target/", "asdc-controller*.war", "asdc-controller.war");
64 JavaArchive testclasses = ShrinkWrap.create(JavaArchive.class, "testClasses.jar");
66 testclasses.addPackage("org.openecomp.mso.filesearching");
68 warArchive.addAsLibraries(testclasses);
70 Testable.archiveToTest(warArchive);
75 public void beforeEachTest() {
76 LogFileSearching.initFile("/tmp/mso-log-checker.log");
80 public void afterEachTest() {
81 LogFileSearching.closeFile();
85 @OperateOnDeployment("log-check")
86 public void testJbossServerLog() throws IOException {
88 File serverLogs = new File("/opt/jboss/standalone/log");
89 //File serverLogs = new File("/tmp/jbosslogs/server.log");
91 assertFalse(LogFileSearching.searchInDirectoryForCommonIssues(null, serverLogs));
96 @OperateOnDeployment("log-check")
97 public void testMSOLog() throws IOException {
98 //File serverLogs = new File("/opt/app/mso/jboss-eap-6.2/standalone/log/server.log");
99 File msoLogs = new File("/var/log/ecomp/MSO");
101 assertFalse(LogFileSearching.searchInDirectoryForCommonIssues(null, msoLogs));