Openliberty arquillian testing - junit4

I'm running into an issue when running an integration test with arquillian against openliberty. Basically it is timing out on the deployment. Apparently you can set appDeployTimeout which I have done. However it does not appear to be loaded as it times out at the same time.
Am I missing something? Can I set this in server.xml?
EDIT 1: Logging:
[INFO] Running za.co.nb.offermanagement.apis.resources.RecalculateOfferIT
Picked up JAVA_TOOL_OPTIONS: -Dcom.ibm.ws.logging.console.log.level=INFO -Dsystem.context.root=/weboffer
Launching defaultServer (Open Liberty 21.0.0.11/wlp-1.0.58.cl211120211019-1900) on OpenJDK 64-Bit Server VM, version 1.8.0_312-b07 (en_ZA)
[AUDIT ] CWWKE0001I: The server defaultServer has been launched.
[AUDIT ] CWWKG0093A: Processing configuration drop-ins resource: C:\Users\cc327150\dev\projects\nedbank\bpmexjee-offermanagement\WebOfferManagement\target\liberty\wlp\usr\servers\defaultServer\configDropins\overrides\liberty-plugin-variable-config.xml
[INFO ] CWWKE0002I: The kernel started after 3.386 seconds
[INFO ] CWWKF0007I: Feature update started.
[INFO ] Aries Blueprint packages not available. So namespaces will not be registered
[AUDIT ] CWWKZ0058I: Monitoring dropins for applications.
[AUDIT ] CWWKI0001I: The CORBA name server is now available at corbaloc:iiop:localhost:2809/NameService.
[WARNING ] CWWKZ0014W: The application weboffer could not be started as it could not be found at location weboffer.war.
[INFO ] CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host * (IPv6) port 9080.
[AUDIT ] CWWKF0012I: The server installed the following features: [ejb-3.2, ejbHome-3.2, ejbLite-3.2, ejbPersistentTimer-3.2, ejbRemote-3.2, jaxrs-2.1, jaxrsClient-2.1, jca-1.7, jdbc-4.1, jndi-1.0, jsonp-1.1, localConnector-1.0, mdb-3.2, servlet-4.0].
[INFO ] CWWKF0008I: Feature update completed in 8.636 seconds.
[AUDIT ] CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 12.014 seconds.
[ERROR ] CWWKZ0013E: It is not possible to start two applications called weboffer.
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: Listing all apps...
[INFO ] SESN8501I: The session manager did not find a persistent storage location; HttpSession objects will be stored in the local application server's memory.
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: Size of results: 43
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=Metaspace
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=PS Old Gen
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Runtime
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:service=permissionadmin,version=1.2,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.websphere.config.mbeans.FeatureListMBean
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=GarbageCollector,name=PS Scavenge
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Threading
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.websphere.runtime.update.RuntimeUpdateNotificationMBean
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=PS Eden Space
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.nio:type=BufferPool,name=mapped
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: jdk.management.jfr:type=FlightRecorder
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.ws.jmx.mbeans.sessionManagerMBean
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=Compressed Class Space
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.ws.config.serverSchemaGenerator
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=kernel,name=ServerInfo
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=PS Survivor Space
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.util.logging:type=Logging
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.compendium:service=cm,version=1.3,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=bundleState,version=1.7,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=packageState,version=1.5,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Compilation
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.ws.jmx.mbeans.generatePluginConfig
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=OperatingSystem
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=PluginUtility,name=PluginConfigRequester
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: JMImplementation:type=MBeanServerDelegate
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryManager,name=Metaspace Manager
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=channelfw,type=endpoint,name=defaultHttpEndpoint
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=ClassLoading
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: com.sun.management:type=HotSpotDiagnostic
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.websphere.config.mbeans.ServerXMLConfigurationMBean
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryManager,name=CodeCacheManager
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=ejbPersistentTimer,type=EJBPersistentTimerService,name=EJBPersistentTimerService
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=Code Cache
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=framework,version=1.7,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=persistence,type=DDLGenerationMBean,name=DDLGenerationMBean
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.nio:type=BufferPool,name=direct
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=serviceState,version=1.7,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:service=com.ibm.websphere.application.ApplicationMBean,name=weboffer
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=kernel,name=ServerEndpointControl
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=GarbageCollector,name=PS MarkSweep
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: com.sun.management:type=DiagnosticCommand
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:service=com.ibm.ws.kernel.filemonitor.FileNotificationMBean
Nov 24, 2021 2:30:17 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Memory
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: Listing all apps...
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: Size of results: 43
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=Metaspace
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=PS Old Gen
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Runtime
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:service=permissionadmin,version=1.2,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.websphere.config.mbeans.FeatureListMBean
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=GarbageCollector,name=PS Scavenge
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Threading
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.websphere.runtime.update.RuntimeUpdateNotificationMBean
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=PS Eden Space
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.nio:type=BufferPool,name=mapped
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: jdk.management.jfr:type=FlightRecorder
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.ws.jmx.mbeans.sessionManagerMBean
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=Compressed Class Space
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.ws.config.serverSchemaGenerator
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=kernel,name=ServerInfo
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=PS Survivor Space
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.util.logging:type=Logging
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.compendium:service=cm,version=1.3,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=bundleState,version=1.7,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=packageState,version=1.5,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Compilation
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.ws.jmx.mbeans.generatePluginConfig
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=OperatingSystem
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=PluginUtility,name=PluginConfigRequester
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: JMImplementation:type=MBeanServerDelegate
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryManager,name=Metaspace Manager
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=channelfw,type=endpoint,name=defaultHttpEndpoint
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=ClassLoading
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: com.sun.management:type=HotSpotDiagnostic
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:name=com.ibm.websphere.config.mbeans.ServerXMLConfigurationMBean
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryManager,name=CodeCacheManager
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=ejbPersistentTimer,type=EJBPersistentTimerService,name=EJBPersistentTimerService
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=MemoryPool,name=Code Cache
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=framework,version=1.7,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=persistence,type=DDLGenerationMBean,name=DDLGenerationMBean
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.nio:type=BufferPool,name=direct
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: osgi.core:type=serviceState,version=1.7,framework=org.eclipse.osgi,uuid=1e536b3a-5a70-420e-b7f2-a0d1a4d1bb51
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:service=com.ibm.websphere.application.ApplicationMBean,name=weboffer
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:feature=kernel,name=ServerEndpointControl
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=GarbageCollector,name=PS MarkSweep
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: com.sun.management:type=DiagnosticCommand
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: WebSphere:service=com.ibm.ws.kernel.filemonitor.FileNotificationMBean
Nov 24, 2021 2:30:20 PM io.openliberty.arquillian.managed.WLPManagedContainer logAllApps
INFO: java.lang:type=Memory
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 43.261 s <<< FAILURE! - in za.co.nb.offermanagement.apis.resources.RecalculateOfferIT
[ERROR] za.co.nb.offermanagement.apis.resources.RecalculateOfferIT Time elapsed: 43.257 s <<< ERROR!
org.jboss.arquillian.container.spi.client.container.DeploymentException: Timeout while waiting for "weboffer" ApplicationMBean to reach STARTED. Actual state: STOPPED.
Stopping server defaultServer.
[AUDIT ] CWWKE0055I: Server shutdown requested on Wednesday 24 November 2021 at 2:30 PM. The server defaultServer is shutting down.
[AUDIT ] CWWKE1100I: Waiting for up to 30 seconds for the server to quiesce.
[INFO ] CWWKO0220I: TCP Channel defaultHttpEndpoint has stopped listening for requests on host * (IPv6) port 9080.
[INFO ] CWWKE1101I: Server quiesce complete.
[AUDIT ] CWWKI0002I: The CORBA name server is no longer available at corbaloc:iiop:localhost:2809/NameService.
[AUDIT ] CWWKE0036I: The server defaultServer stopped after 43.785 seconds.
Server defaultServer stopped.
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] RecalculateOfferIT » Deployment Timeout while waiting for "weboffer" Applicati...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
EDIT 2 messages.log:
********************************************************************************
product = Open Liberty 21.0.0.11 (wlp-1.0.58.cl211120211019-1900)
wlp.install.dir = C:/Users/cc327150/dev/projects/nedbank/bpmexjee-offermanagement/WebOfferManagement/target/liberty/wlp/
java.home = C:\Users\cc327150\dev\tools\jdk8u312\jre
java.version = 1.8.0_312
java.runtime = OpenJDK Runtime Environment (1.8.0_312-b07)
os = Windows 10 (10.0; amd64) (en_ZA)
process = 18348#V105P10PRA4704
********************************************************************************
[2021/11/25 15:29:37:212 CAT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager A CWWKE0001I: The server defaultServer has been launched.
[2021/11/25 15:30:01:917 CAT] 00000013 com.ibm.ws.config.xml.internal.ServerXMLConfiguration A CWWKG0093A: Processing configuration drop-ins resource: C:\Users\cc327150\dev\projects\nedbank\bpmexjee-offermanagement\WebOfferManagement\target\liberty\wlp\usr\servers\defaultServer\configDropins\overrides\liberty-plugin-variable-config.xml
[2021/11/25 15:30:02:520 CAT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager I CWWKE0002I: The kernel started after 26.211 seconds
[2021/11/25 15:30:03:573 CAT] 0000001c com.ibm.ws.kernel.feature.internal.FeatureManager I CWWKF0007I: Feature update started.
[2021/11/25 15:30:12:061 CAT] 00000014 .apache.cxf.cxf.core.3.2:1.0.58.cl211120211019-1900(id=149)] I Aries Blueprint packages not available. So namespaces will not be registered
[2021/11/25 15:30:12:781 CAT] 00000013 com.ibm.ws.app.manager.internal.monitor.DropinMonitor A CWWKZ0058I: Monitoring dropins for applications.
[2021/11/25 15:30:14:909 CAT] 00000014 com.ibm.ws.transport.iiop.internal.ORBWrapperInternal A CWWKI0001I: The CORBA name server is now available at corbaloc:iiop:localhost:2809/NameService.
[2021/11/25 15:30:16:598 CAT] 0000001f com.ibm.ws.app.manager.AppMessageHelper W CWWKZ0014W: The application weboffer could not be started as it could not be found at location weboffer.war.
[2021/11/25 15:30:16:614 CAT] 0000001c com.ibm.ws.tcpchannel.internal.TCPPort I CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host * (IPv6) port 9080.
[2021/11/25 15:30:16:786 CAT] 0000001c com.ibm.ws.kernel.feature.internal.FeatureManager A CWWKF0012I: The server installed the following features: [ejb-3.2, ejbHome-3.2, ejbLite-3.2, ejbPersistentTimer-3.2, ejbRemote-3.2, jaxrs-2.1, jaxrsClient-2.1, jca-1.7, jdbc-4.1, jndi-1.0, jsonp-1.1, localConnector-1.0, mdb-3.2, servlet-4.0].
[2021/11/25 15:30:16:786 CAT] 0000001c com.ibm.ws.kernel.feature.internal.FeatureManager I CWWKF0008I: Feature update completed in 14.273 seconds.
[2021/11/25 15:30:16:786 CAT] 0000001c com.ibm.ws.kernel.feature.internal.FeatureManager A CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 40.472 seconds.
[2021/11/25 15:30:17:177 CAT] 0000000f com.ibm.ws.kernel.launch.internal.ServerCommandListener A CWWKE0055I: Server shutdown requested on Thursday 25 November 2021 at 3:30 PM. The server defaultServer is shutting down.
[2021/11/25 15:30:17:724 CAT] 00000029 com.ibm.ws.runtime.update.internal.RuntimeUpdateManagerImpl A CWWKE1100I: Waiting for up to 30 seconds for the server to quiesce.
[2021/11/25 15:30:17:756 CAT] 0000001e com.ibm.ws.tcpchannel.internal.TCPChannel I CWWKO0220I: TCP Channel defaultHttpEndpoint has stopped listening for requests on host * (IPv6) port 9080.
[2021/11/25 15:30:17:776 CAT] 00000029 com.ibm.ws.runtime.update.internal.RuntimeUpdateManagerImpl I CWWKE1101I: Server quiesce complete.
[2021/11/25 15:30:17:931 CAT] 00000029 com.ibm.ws.transport.iiop.internal.ORBWrapperInternal A CWWKI0002I: The CORBA name server is no longer available at corbaloc:iiop:localhost:2809/NameService.
[2021/11/25 15:30:20:081 CAT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager A CWWKE0036I: The server defaultServer stopped after 43.771 seconds.
EDIT 3:
<server description="Sample Liberty server">
<featureManager>
<feature>jaxrs-2.1</feature>
<feature>jsonp-1.1</feature>
<feature>localConnector-1.0</feature>
<feature>servlet-4.0</feature>
<feature>ejb-3.2</feature>
</featureManager>
<variable name="default.http.port" defaultValue="9080"/>
<variable name="default.https.port" defaultValue="9443"/>
<webApplication location="weboffer.war" contextRoot="/" />
<applicationManager startTimeout="200s" />
<applicationMonitor updateTrigger="mbean" />
<httpEndpoint host="*" httpPort="${default.http.port}"
httpsPort="${default.https.port}" id="defaultHttpEndpoint"/>
</server>

Which Jakarta EE version you are using?
I have created some template and projects for Jakarta EE 8 and 9 in the past years.
Check the Jakarta EE 8 template project and Jakarta EE 9 template project, both include Arquillian OpenLiberty managed and remote adapter configuration, note read the related docs for details, links provided in the readme of these projects.
For the arqullian.xml configuration, check Jakarta EE 9 readme.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<engine>
<property name="deploymentExportPath">target/</property>
</engine>
<container qualifier="liberty-remote">
<configuration>
<property name="hostName">localhost</property>
<property name="serverName">defaultServer</property>
<property name="username">admin</property>
<property name="password">admin</property>
<property name="httpPort">9080</property>
<property name="httpsPort">9443</property>
<!-- change appDeployTimeout here -->
<property name="appDeployTimeout">120</property>
</configuration>
</container>
</arquillian>

Related

KDB string to kdb `timestamp`

kdb mortals/gods!!
I have an array of datetime string but in a different format
> leads[`firstConversion]
"Wed May 20 2020 08:56:54 GMT-0700 (PDT)"
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"
"Wed May 20 2020 08:56:57 GMT-0700 (PDT)"
"Wed May 20 2020 08:56:58 GMT-0700 (PDT)"
"Wed May 20 2020 08:56:58 GMT-0700 (PDT)"
"Wed May 20 2020 08:56:59 GMT-0700 (PDT)"
"Wed May 20 2020 08:57:00 GMT-0700 (PDT)"
"Wed May 20 2020 08:57:01 GMT-0700 (PDT)"
"Wed May 20 2020 09:06:32 GMT-0700 (PDT)"
"Wed May 20 2020 09:06:32 GMT-0700 (PDT)"
"Wed May 20 2020 09:06:33 GMT-0700 (PDT)"
"Wed May 20 2020 09:06:33 GMT-0700 (PDT)"
"Wed May 20 2020 09:06:35 GMT-0700 (PDT)"
"Wed May 20 2020 09:06:35 GMT-0700 (PDT)"
"Wed May 20 2020 09:07:07 GMT-0700 (PDT)"
"Wed May 20 2020 09:07:09 GMT-0700 (PDT)"
"Wed May 20 2020 09:07:09 GMT-0700 (PDT)"
"Wed May 20 2020 09:07:10 GMT-0700 (PDT)"
what would be the best way to convert them into native kdb timestamp 2020.05.20D09:07:10.0000?
Depending on how predictable/consistent the indices of the relevant part of each string is.. something like the below
q)x!"P"$4_'x
"Wed May 20 2020 08:56:54 GMT-0700 (PDT)"| 2020.05.20D08:56:54.000000000
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"| 2020.05.20D08:56:56.000000000
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"| 2020.05.20D08:56:56.000000000
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"| 2020.05.20D08:56:56.000000000
"Wed May 20 2020 08:56:57 GMT-0700 (PDT)"| 2020.05.20D08:56:57.000000000
q)
q)// or
q)
q)i:4+til -4+count first x
q)x!"P"$x[;i]
"Wed May 20 2020 08:56:54 GMT-0700 (PDT)"| 2020.05.20D08:56:54.000000000
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"| 2020.05.20D08:56:56.000000000
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"| 2020.05.20D08:56:56.000000000
"Wed May 20 2020 08:56:56 GMT-0700 (PDT)"| 2020.05.20D08:56:56.000000000
"Wed May 20 2020 08:56:57 GMT-0700 (PDT)"| 2020.05.20D08:56:57.000000000
q)
q)x:2000000#x
q)
q)\ts "P"$4_'x
495 161554832
q)\ts "P"$x[;i]
538 161554768
You could use the .qdate library https://code.kx.com/developer/libraries/date-parser/
It can parse to UTC or leave in original timezone:
q).qdate.resolve["%a %b %d %Y %T %z"] "Wed May 20 2020 09:07:10 GMT-0700 (PDT)"
2020.05.20D16:07:10.000000000
q).qdate.resolve["%a %b %d %Y %T"] "Wed May 20 2020 09:07:10 GMT-0700 (PDT)"
2020.05.20D09:07:10.000000000
Here's one way:
q)t:("Wed May 20 2020 09:07:09 GMT-0700 (PDT)";"Wed May 20 2020 09:07:10 GMT-0700 (PDT)");
q)update stamp:"P"$" "0:(date;month;year;time) from flip `month`date`year`time!(" SIIT";" ")0:t
month date year time stamp
----------------------------------------------------------
May 20 2020 09:07:09.000 2020.05.20D09:07:09.000000000
May 20 2020 09:07:10.000 2020.05.20D09:07:10.000000000

Pacemaker dont start resource jboss and pgsql

I test pacemaker on two servers.
On two nodes stands CentOS 7 x64
jdk-7u80-linux-x64
JBoss 7.1.1 Final
Pgsql (PostgreSQL) 9.2.24
pcs --version
0.9.165
Set up 3 resources. IPaddr2 works without problems. But with jboss and pgsql problems.
What if they run teams
/bin/sh /usr/lib/ocf/resource.d/heartbeat/pgsql start
/bin/sh /usr/lib/ocf/resource.d/heartbeat/jboss start
they work, but the pacemaker does not see them.
[root # centos-test1 heartbeat] # pcs status --all
Cluster name: test
Stack: corosync
Current DC: centos-test1 (version 1.1.19-8.el7_6.2-c3c624ea3d) - partition with quorum
Last updated: Wed Dec 26 06:58:21 2018
Last change: Wed Dec 26 06:07:27 2018 by root via cibadmin on centos-test1
2 nodes configured
3 resources configured
Online: [centos-test1 centos-test2]
Full list of resources:
virtual_ip (ocf :: heartbeat: ipaddr2): Started centos-test1
jboss (ocf :: heartbeat: jboss): Stopped
pgsql (ocf :: heartbeat: pgsql): Stopped
Failed Actions:
* jboss_start_0 on centos-test1 'unknown error' (1): call = 18, status = Timed Out, exitreason = '',
    last-rc-change = 'Wed Dec 26 06:08:16 2018', queued = 0ms, exec = 20002ms
* pgsql_start_0 on centos-test1 'not configured' (6): call = 15, status = complete, exitreason = '',
    last-rc-change = 'Wed Dec 26 06:07:56 2018', queued = 0ms, exec = 115ms
* jboss_start_0 on centos-test2 'unknown error' (1): call = 14, status = Timed Out, exitreason = '',
    last-rc-change = 'Wed Dec 26 13:07:04 2018', queued = 0ms, exec = 20002ms
Daemon Status:
  corosync: active / enabled
  pacemaker: active / enabled
  pcsd: active / enabled
  
In ocf :: heartbeat: there were errors with environment variables, we had to explicitly indicate in the files:
# Initialization:
: / usr / lib / ocf / lib / heartbeat
. / usr / lib / ocf / lib / heartbeat / ocf-shellfuncs
#: $ {OCF_FUNCTIONS_DIR = $ {OCF_ROOT} / lib / heartbeat}
# $ {OCF_FUNCTIONS_DIR} / ocf-shellfuncs
corasync.log
Dec 26 14:19:21 [27771] centos-test1 pengine: info: common_print: virtual_ip (ocf::heartbeat:IPaddr2): Started centos-test1
Dec 26 14:19:21 [27771] centos-test1 pengine: info: common_print: jboss (ocf::heartbeat:jboss): FAILED centos-test1
Dec 26 14:19:21 [27771] centos-test1 pengine: info: common_print: pgsql (ocf::heartbeat:pgsql): Stopped
Dec 26 14:19:21 [27771] centos-test1 pengine: info: pe_get_failcount: jboss has failed INFINITY times on centos-test1
Dec 26 14:19:21 [27771] centos-test1 pengine: warning: check_migration_threshold: Forcing jboss away from centos-test1 after 1000000 failures (max=1000000)
Dec 26 14:19:21 [27771] centos-test1 pengine: info: pe_get_failcount: pgsql has failed INFINITY times on centos-test1
Dec 26 14:19:21 [27771] centos-test1 pengine: warning: check_migration_threshold: Forcing pgsql away from centos-test1 after 1000000 failures (max=1000000)
Dec 26 14:19:21 [27771] centos-test1 pengine: info: pe_get_failcount: jboss has failed INFINITY times on centos-test2
Dec 26 14:19:21 [27771] centos-test1 pengine: warning: check_migration_threshold: Forcing jboss away from centos-test2 after 1000000 failures (max=1000000)
Dec 26 14:19:21 [27771] centos-test1 pengine: info: native_color: Resource jboss cannot run anywhere
Dec 26 14:19:21 [27771] centos-test1 pengine: info: native_color: Resource pgsql cannot run anywhere
Dec 26 14:19:21 [27771] centos-test1 pengine: info: LogActions: Leave virtual_ip (Started centos-test1)
Dec 26 14:19:21 [27771] centos-test1 pengine: notice: LogAction: * Stop jboss ( centos-test1 ) due to node availability
Dec 26 14:19:21 [27771] centos-test1 pengine: info: LogActions: Leave pgsql (Stopped)
Dec 26 14:19:21 [27771] centos-test1 pengine: notice: process_pe_message: Calculated transition 5, saving inputs in /var/lib/pacemaker/pengine/pe-input-266.bz2
Dec 26 14:19:21 [27772] centos-test1 crmd: info: do_state_transition: State transition S_POLICY_ENGINE -> S_TRANSITION_ENGINE | input=I_PE_SUCCESS cause=C_IPC_MESSAGE origin=handle_response
Dec 26 14:19:21 [27772] centos-test1 crmd: info: do_te_invoke: Processing graph 5 (ref=pe_calc-dc-1545823161-30) derived from /var/lib/pacemaker/pengine/pe-input-266.bz2
Dec 26 14:19:21 [27772] centos-test1 crmd: notice: te_rsc_command: Initiating stop operation jboss_stop_0 locally on centos-test1 | action 2
Dec 26 14:19:21 [27772] centos-test1 crmd: info: do_lrm_rsc_op: Performing key=2:5:0:19594a89-d772-4748-8c9a-5a7888a82914 op=jboss_stop_0
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_process_request: Forwarding cib_modify operation for section status to all (origin=local/crmd/54)
Dec 26 14:19:21 [27769] centos-test1 lrmd: info: log_execute: executing - rsc:jboss action:stop call_id:18
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: Diff: --- 0.15.35 2
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: Diff: +++ 0.15.36 (null)
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: + /cib: #num_updates=36
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: + /cib/status/node_state[#id='1']/lrm[#id='1']/lrm_resources/lrm_resource[#id='jboss']/lrm_rsc_op[#id='jboss_last_0']: #operation_key=jboss_stop_0, #operation=stop, #transition-key=2:5:0:19594a89-d772-4748-8c9a-5a7888a82914, #transition-magic=-1:193;2:5:0:19594a89-d772-4748-8c9a-5a7888a82914, #call-id=-1, #rc-code=193, #op-status=-1, #last-run=1545823161, #last-rc-change=1545823161, #exec-time=0
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_process_request: Completed cib_modify operation for section status: OK (rc=0, origin=centos-test1/crmd/54, version=0.15.36)
Dec 26 14:19:21 jboss(jboss)[28346]: INFO: JBoss[jboss] is already stopped.
Dec 26 14:19:21 [27769] centos-test1 lrmd: info: log_finished: finished - rsc:jboss action:stop call_id:18 pid:28346 exit-code:0 exec-time:21ms queue-time:0ms
Dec 26 14:19:21 [27772] centos-test1 crmd: notice: process_lrm_event: Result of stop operation for jboss on centos-test1: 0 (ok) | call=18 key=jboss_stop_0 confirmed=true cib-update=55
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_process_request: Forwarding cib_modify operation for section status to all (origin=local/crmd/55)
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: Diff: --- 0.15.36 2
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: Diff: +++ 0.15.37 (null)
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: + /cib: #num_updates=37
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_perform_op: + /cib/status/node_state[#id='1']/lrm[#id='1']/lrm_resources/lrm_resource[#id='jboss']/lrm_rsc_op[#id='jboss_last_0']: #transition-magic=0:0;2:5:0:19594a89-d772-4748-8c9a-5a7888a82914, #call-id=18, #rc-code=0, #op-status=0, #exec-time=21
Dec 26 14:19:21 [27767] centos-test1 cib: info: cib_process_request: Completed cib_modify operation for section status: OK (rc=0, origin=centos-test1/crmd/55, version=0.15.37)
Dec 26 14:19:21 [27772] centos-test1 crmd: info: match_graph_event: Action jboss_stop_0 (2) confirmed on centos-test1 (rc=0)
Dec 26 14:19:21 [27772] centos-test1 crmd: notice: run_graph: Transition 5 (Complete=2, Pending=0, Fired=0, Skipped=0, Incomplete=0, Source=/var/lib/pacemaker/pengine/pe-input-266.bz2): Complete
Dec 26 14:19:21 [27772] centos-test1 crmd: info: do_log: Input I_TE_SUCCESS received in state S_TRANSITION_ENGINE from notify_crmd
Dec 26 14:19:21 [27772] centos-test1 crmd: notice: do_state_transition: State transition S_TRANSITION_ENGINE -> S_IDLE | input=I_TE_SUCCESS cause=C_FSA_INTERNAL origin=notify_crmd
Dec 26 14:19:26 [27767] centos-test1 cib: info: cib_process_ping: Reporting our current digest to centos-test1: 1441d742a8ffbf1c1f45b9d38dd1a776 for 0.15.37 (0x55a05cd6c580 0)
Boht resource have reached max cap on number of retries to start. the cluster has given up on them.
crm_resource can be of help to reset failcount and trigger start of resource on a
node.
You have to cleanup the resources on each of hte node to trigger a restart.
On commandline execute "crm_resource --help" and go to the end for an example of crm_resource --cleanup

freeradius daloradius authentication failure

i followed this tutorial to install freeradius and dalo radius for the raspberry pi:
http://www.binaryheartbeat.net/2013/12/raspberry-pi-based-freeradius-server.html
i tested the file authentication and it worked fine but after installing daloradius and switching to MySQL authnetications fail for unknown reasons
here is freeradius output that occurs when trying to authenticate a user:
rad_recv: Access-Request packet from host 192.168.1.1 port 32779, id=216, length=172
User-Name = "ccc"
State = 0xf9775519ff7f4c9188c14494359a170f
EAP-Message = 0x0208005b190017030100500d2898ca35aa9fa9e4febd8816c9e6deda71960fe5692b7c3d0499f2b5bba6b531483e373e14f8aff517aa081e214edc98e2c8bb22d16a961ecff4f498d20d152535b4d11ace1484b985bd2501ade77b
Service-Type = Framed-User
Framed-MTU = 1420
NAS-IP-Address = 192.168.1.1
Message-Authenticator = 0x49fc781b8a152fbec467b2c1f275a1a1
Tue Dec 29 18:38:47 2015 : Info: # Executing section authorize from file /etc/freeradius/sites-enabled/default
Tue Dec 29 18:38:47 2015 : Info: +group authorize {
Tue Dec 29 18:38:47 2015 : Info: ++[preprocess] = ok
Tue Dec 29 18:38:47 2015 : Info: ++[chap] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[mschap] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[digest] = noop
Tue Dec 29 18:38:47 2015 : Info: [suffix] No '#' in User-Name = "ccc", looking up realm NULL
Tue Dec 29 18:38:47 2015 : Info: [suffix] No such realm "NULL"
Tue Dec 29 18:38:47 2015 : Info: ++[suffix] = noop
Tue Dec 29 18:38:47 2015 : Info: [eap] EAP packet type response id 8 length 91
Tue Dec 29 18:38:47 2015 : Info: [eap] Continuing tunnel setup.
Tue Dec 29 18:38:47 2015 : Info: ++[eap] = ok
Tue Dec 29 18:38:47 2015 : Info: +} # group authorize = ok
Tue Dec 29 18:38:47 2015 : Info: Found Auth-Type = EAP
Tue Dec 29 18:38:47 2015 : Info: # Executing group from file /etc/freeradius/sites-enabled/default
Tue Dec 29 18:38:47 2015 : Info: +group authenticate {
Tue Dec 29 18:38:47 2015 : Info: [eap] Request found, released from the list
Tue Dec 29 18:38:47 2015 : Info: [eap] EAP/peap
Tue Dec 29 18:38:47 2015 : Info: [eap] processing type peap
Tue Dec 29 18:38:47 2015 : Info: [peap] processing EAP-TLS
Tue Dec 29 18:38:47 2015 : Info: [peap] eaptls_verify returned 7
Tue Dec 29 18:38:47 2015 : Info: [peap] Done initial handshake
Tue Dec 29 18:38:47 2015 : Info: [peap] eaptls_process returned 7
Tue Dec 29 18:38:47 2015 : Info: [peap] EAPTLS_OK
Tue Dec 29 18:38:47 2015 : Info: [peap] Session established. Decoding tunneled attributes.
Tue Dec 29 18:38:47 2015 : Info: [peap] Peap state phase2
Tue Dec 29 18:38:47 2015 : Info: [peap] EAP type mschapv2
Tue Dec 29 18:38:47 2015 : Info: [peap] Got tunneled request
EAP-Message = 0x0208003e1a0208003931461c2f1334a4b7bab38912e9d82dd97b000000000000000070fb7810a938a00d884f17dc01b62eaa7dde9fbb7ab2cf4200636363
server {
Tue Dec 29 18:38:47 2015 : Info: [peap] Setting User-Name to ccc
Sending tunneled request
EAP-Message = 0x0208003e1a0208003931461c2f1334a4b7bab38912e9d82dd97b000000000000000070fb7810a938a00d884f17dc01b62eaa7dde9fbb7ab2cf4200636363
FreeRADIUS-Proxied-To = 127.0.0.1
User-Name = "ccc"
State = 0x4bb6eef44bbef48a7072f4e023895561
server inner-tunnel {
Tue Dec 29 18:38:47 2015 : Info: # Executing section authorize from file /etc/freeradius/sites-enabled/inner-tunnel
Tue Dec 29 18:38:47 2015 : Info: +group authorize {
Tue Dec 29 18:38:47 2015 : Info: ++[chap] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[mschap] = noop
Tue Dec 29 18:38:47 2015 : Info: [suffix] No '#' in User-Name = "ccc", looking up realm NULL
Tue Dec 29 18:38:47 2015 : Info: [suffix] No such realm "NULL"
Tue Dec 29 18:38:47 2015 : Info: ++[suffix] = noop
Tue Dec 29 18:38:47 2015 : Info: ++update control {
Tue Dec 29 18:38:47 2015 : Info: ++} # update control = noop
Tue Dec 29 18:38:47 2015 : Info: [eap] EAP packet type response id 8 length 62
Tue Dec 29 18:38:47 2015 : Info: [eap] No EAP Start, assuming it's an on-going EAP conversation
Tue Dec 29 18:38:47 2015 : Info: ++[eap] = updated
Tue Dec 29 18:38:47 2015 : Info: ++[files] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[expiration] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[logintime] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[pap] = noop
Tue Dec 29 18:38:47 2015 : Info: +} # group authorize = updated
Tue Dec 29 18:38:47 2015 : Info: Found Auth-Type = EAP
Tue Dec 29 18:38:47 2015 : Info: # Executing group from file /etc/freeradius/sites-enabled/inner-tunnel
Tue Dec 29 18:38:47 2015 : Info: +group authenticate {
Tue Dec 29 18:38:47 2015 : Info: [eap] Request found, released from the list
Tue Dec 29 18:38:47 2015 : Info: [eap] EAP/mschapv2
Tue Dec 29 18:38:47 2015 : Info: [eap] processing type mschapv2
Tue Dec 29 18:38:47 2015 : Info: [mschapv2] # Executing group from file /etc/freeradius/sites-enabled/inner-tunnel
Tue Dec 29 18:38:47 2015 : Info: [mschapv2] +group MS-CHAP {
Tue Dec 29 18:38:47 2015 : Info: [mschap] No Cleartext-Password configured. Cannot create LM-Password.
Tue Dec 29 18:38:47 2015 : Info: [mschap] No Cleartext-Password configured. Cannot create NT-Password.
Tue Dec 29 18:38:47 2015 : Info: [mschap] Creating challenge hash with username: ccc
Tue Dec 29 18:38:47 2015 : Info: [mschap] Client is using MS-CHAPv2 for ccc, we need NT-Password
Tue Dec 29 18:38:47 2015 : Info: [mschap] FAILED: No NT/LM-Password. Cannot perform authentication.
Tue Dec 29 18:38:47 2015 : Info: [mschap] FAILED: MS-CHAP2-Response is incorrect
Tue Dec 29 18:38:47 2015 : Info: ++[mschap] = reject
Tue Dec 29 18:38:47 2015 : Info: +} # group MS-CHAP = reject
Tue Dec 29 18:38:47 2015 : Info: [eap] Freeing handler
Tue Dec 29 18:38:47 2015 : Info: ++[eap] = reject
Tue Dec 29 18:38:47 2015 : Info: +} # group authenticate = reject
Tue Dec 29 18:38:47 2015 : Info: Failed to authenticate the user.
Tue Dec 29 18:38:47 2015 : Info: Using Post-Auth-Type REJECT
Tue Dec 29 18:38:47 2015 : Info: # Executing group from file /etc/freeradius/sites-enabled/inner-tunnel
Tue Dec 29 18:38:47 2015 : Info: +group REJECT {
Tue Dec 29 18:38:47 2015 : Info: [attr_filter.access_reject] expand: %{User-Name} -> ccc
Tue Dec 29 18:38:47 2015 : Debug: attr_filter: Matched entry DEFAULT at line 11
Tue Dec 29 18:38:47 2015 : Info: ++[attr_filter.access_reject] = updated
Tue Dec 29 18:38:47 2015 : Info: +} # group REJECT = updated
} # server inner-tunnel
Tue Dec 29 18:38:47 2015 : Info: [peap] Got tunneled reply code 3
MS-CHAP-Error = "\010E=691 R=1"
EAP-Message = 0x04080004
Message-Authenticator = 0x00000000000000000000000000000000
Tue Dec 29 18:38:47 2015 : Info: [peap] Got tunneled reply RADIUS code 3
MS-CHAP-Error = "\010E=691 R=1"
EAP-Message = 0x04080004
Message-Authenticator = 0x00000000000000000000000000000000
Tue Dec 29 18:38:47 2015 : Info: [peap] Tunneled authentication was rejected.
Tue Dec 29 18:38:47 2015 : Info: [peap] FAILURE
Tue Dec 29 18:38:47 2015 : Info: ++[eap] = handled
Tue Dec 29 18:38:47 2015 : Info: +} # group authenticate = handled
Sending Access-Challenge of id 216 to 192.168.1.1 port 32779
EAP-Message = 0x0109002b190017030100205991bfd8f9e7f70794477d653c848e8b443626b3b935a5b3f049ac7af1534d3e
Message-Authenticator = 0x00000000000000000000000000000000
State = 0xf9775519fe7e4c9188c14494359a170f
Tue Dec 29 18:38:47 2015 : Info: Finished request 7.
Tue Dec 29 18:38:47 2015 : Debug: Going to the next request
Tue Dec 29 18:38:47 2015 : Debug: Waking up in 0.4 seconds.
rad_recv: Access-Request packet from host 192.168.1.1 port 32779, id=217, length=124
User-Name = "ccc"
State = 0xf9775519fe7e4c9188c14494359a170f
EAP-Message = 0x0209002b190017030100202a7f1a72de2970b689e44c005661d1e1e444854af7499ebeb23eabc7bfad7b64
Service-Type = Framed-User
Framed-MTU = 1420
NAS-IP-Address = 192.168.1.1
Message-Authenticator = 0xc9b0d8e268df2d8e4b484725c3efa189
Tue Dec 29 18:38:47 2015 : Info: # Executing section authorize from file /etc/freeradius/sites-enabled/default
Tue Dec 29 18:38:47 2015 : Info: +group authorize {
Tue Dec 29 18:38:47 2015 : Info: ++[preprocess] = ok
Tue Dec 29 18:38:47 2015 : Info: ++[chap] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[mschap] = noop
Tue Dec 29 18:38:47 2015 : Info: ++[digest] = noop
Tue Dec 29 18:38:47 2015 : Info: [suffix] No '#' in User-Name = "ccc", looking up realm NULL
Tue Dec 29 18:38:47 2015 : Info: [suffix] No such realm "NULL"
Tue Dec 29 18:38:47 2015 : Info: ++[suffix] = noop
Tue Dec 29 18:38:47 2015 : Info: [eap] EAP packet type response id 9 length 43
Tue Dec 29 18:38:47 2015 : Info: [eap] Continuing tunnel setup.
Tue Dec 29 18:38:47 2015 : Info: ++[eap] = ok
Tue Dec 29 18:38:47 2015 : Info: +} # group authorize = ok
Tue Dec 29 18:38:47 2015 : Info: Found Auth-Type = EAP
Tue Dec 29 18:38:47 2015 : Info: # Executing group from file /etc/freeradius/sites-enabled/default
Tue Dec 29 18:38:47 2015 : Info: +group authenticate {
Tue Dec 29 18:38:47 2015 : Info: [eap] Request found, released from the list
Tue Dec 29 18:38:47 2015 : Info: [eap] EAP/peap
Tue Dec 29 18:38:47 2015 : Info: [eap] processing type peap
Tue Dec 29 18:38:47 2015 : Info: [peap] processing EAP-TLS
Tue Dec 29 18:38:47 2015 : Info: [peap] eaptls_verify returned 7
Tue Dec 29 18:38:47 2015 : Info: [peap] Done initial handshake
Tue Dec 29 18:38:47 2015 : Info: [peap] eaptls_process returned 7
Tue Dec 29 18:38:47 2015 : Info: [peap] EAPTLS_OK
Tue Dec 29 18:38:47 2015 : Info: [peap] Session established. Decoding tunneled attributes.
Tue Dec 29 18:38:47 2015 : Info: [peap] Peap state send tlv failure
Tue Dec 29 18:38:47 2015 : Info: [peap] Received EAP-TLV response.
Tue Dec 29 18:38:47 2015 : Info: [peap] The users session was previously rejected: returning reject (again.)
Tue Dec 29 18:38:47 2015 : Info: [peap] *** This means you need to read the PREVIOUS messages in the debug output
Tue Dec 29 18:38:47 2015 : Info: [peap] *** to find out the reason why the user was rejected.
Tue Dec 29 18:38:47 2015 : Info: [peap] *** Look for "reject" or "fail". Those earlier messages will tell you.
Tue Dec 29 18:38:47 2015 : Info: [peap] *** what went wrong, and how to fix the problem.
Tue Dec 29 18:38:47 2015 : Info: [eap] Handler failed in EAP/peap
Tue Dec 29 18:38:47 2015 : Info: [eap] Failed in EAP select
Tue Dec 29 18:38:47 2015 : Info: ++[eap] = invalid
Tue Dec 29 18:38:47 2015 : Info: +} # group authenticate = invalid
Tue Dec 29 18:38:47 2015 : Info: Failed to authenticate the user.
Tue Dec 29 18:38:47 2015 : Info: Using Post-Auth-Type REJECT
Tue Dec 29 18:38:47 2015 : Info: # Executing group from file /etc/freeradius/sites-enabled/default
Tue Dec 29 18:38:47 2015 : Info: +group REJECT {
Tue Dec 29 18:38:47 2015 : Info: [sql] expand: %{User-Name} -> ccc
Tue Dec 29 18:38:47 2015 : Info: [sql] sql_set_user escaped user --> 'ccc'
Tue Dec 29 18:38:47 2015 : Info: [sql] expand: %{User-Password} ->
Tue Dec 29 18:38:47 2015 : Info: [sql] ... expanding second conditional
Tue Dec 29 18:38:47 2015 : Info: [sql] expand: %{Chap-Password} ->
Tue Dec 29 18:38:47 2015 : Info: [sql] expand: INSERT INTO radpostauth (username, pass, reply, authdate) VALUES ( '%{User-Name}', '%{%{User-Password}:-%{Chap-Password}}', '%{reply:Packet-Type}', '%S') -> INSERT INTO radpostauth (username, pass, reply, authdate) VALUES ( 'ccc', '', 'Access-Reject', '2015-12-29 18:38:47')
Tue Dec 29 18:38:47 2015 : Debug: rlm_sql (sql) in sql_postauth: query is INSERT INTO radpostauth (username, pass, reply, authdate) VALUES ( 'ccc', '', 'Access-Reject', '2015-12-29 18:38:47')
Tue Dec 29 18:38:47 2015 : Debug: rlm_sql (sql): Reserving sql socket id: 29
Tue Dec 29 18:38:47 2015 : Debug: rlm_sql (sql): Released sql socket id: 29
Tue Dec 29 18:38:47 2015 : Info: ++[sql] = ok
Tue Dec 29 18:38:47 2015 : Info: [attr_filter.access_reject] expand: %{User-Name} -> ccc
Tue Dec 29 18:38:47 2015 : Debug: attr_filter: Matched entry DEFAULT at line 11
Tue Dec 29 18:38:47 2015 : Info: ++[attr_filter.access_reject] = updated
Tue Dec 29 18:38:47 2015 : Info: +} # group REJECT = updated
Tue Dec 29 18:38:47 2015 : Info: Delaying reject of request 8 for 1 seconds
Tue Dec 29 18:38:47 2015 : Debug: Going to the next request
Tue Dec 29 18:38:47 2015 : Debug: Waking up in 0.1 seconds.
Tue Dec 29 18:38:47 2015 : Info: Cleaning up request 0 ID 209 with timestamp +11
Tue Dec 29 18:38:47 2015 : Debug: Waking up in 0.3 seconds.
Tue Dec 29 18:38:47 2015 : Info: Cleaning up request 1 ID 210 with timestamp +11
Tue Dec 29 18:38:47 2015 : Debug: Waking up in 0.3 seconds.
Tue Dec 29 18:38:48 2015 : Info: Cleaning up request 2 ID 211 with timestamp +12
Tue Dec 29 18:38:48 2015 : Debug: Waking up in 0.1 seconds.
Tue Dec 29 18:38:48 2015 : Info: Sending delayed reject for request 8
Sending Access-Reject of id 217 to 192.168.1.1 port 32779
EAP-Message = 0x04090004
Message-Authenticator = 0x00000000000000000000000000000000
Found the solution,
the problem was that i didn't configure the /etc/raddb/sites-available/inner-tunnel file to use sql

RxJava: Is there an Observable.cachedDefer() operator, or some equivalent?

Is there a safe way to defer the creation of an Observable<T>, but upon creation cache it for a period of time before it must create it again?
Observable.cachedDefer(() -> createExpensiveFiniteObservable().cache(), 5, TimeUnit.MINUTES);
I have data sets that are expensive to construct and I want them cached long enough to support a process, but let them expire approximately between each run.
I've added the functionality to do this to rxjava-extras. The code below depends on rxjava-extras 0.6.8-RC2 or later (which is on Maven Central).
Run the main method below and you will see these results which seem to match the behaviour you desire (a reset of the cache whenever the time gap to next subscribe is >=5 seconds):
source emits Tue Oct 13 21:00:16 AEDT 2015
Tue Oct 13 21:00:16 AEDT 2015
Tue Oct 13 21:00:16 AEDT 2015
Tue Oct 13 21:00:16 AEDT 2015
Tue Oct 13 21:00:16 AEDT 2015
Tue Oct 13 21:00:16 AEDT 2015
source emits Tue Oct 13 21:00:31 AEDT 2015
Tue Oct 13 21:00:31 AEDT 2015
Tue Oct 13 21:00:31 AEDT 2015
Tue Oct 13 21:00:31 AEDT 2015
Tue Oct 13 21:00:31 AEDT 2015
Tue Oct 13 21:00:31 AEDT 2015
source emits Tue Oct 13 21:00:46 AEDT 2015
Tue Oct 13 21:00:46 AEDT 2015
Tue Oct 13 21:00:46 AEDT 2015
...
Main method:
public static void main(String[] args) throws InterruptedException {
Observable<Date> source = Observable
.defer(() ->
Observable
.just(new Date())
.doOnNext(
d -> System.out.println("source emits " + d)));
CloseableObservableWithReset<Date> cached =
Obs.cache(source, 5, TimeUnit.SECONDS, Schedulers.computation());
Observable<Date> o = cached
.observable()
.doOnSubscribe(() -> cached.reset());
for (int i = 0; i < 30; i++) {
o.doOnNext(System.out::println).subscribe();
Thread.sleep((i % 5 + 1)*1000);
}
cached.close();
}
Note that to reset the cache on every emission as well then where you see
.doOnSubscribe(() -> cached.reset())
put
.doOnSubscribe(() -> cached.reset())
.doOnNext(x -> cached.reset())

How to get first day of last month with Perl

So I would like to use function localtime(), but I'm having problems with getting first and last day of last month properly. Right now I have working functionality, but I bet there is a better way to solve this.
use Time::Piece;
use Time::Seconds;
$start_of_month = localtime();
while($start_of_month->mday < 10) {
$start_of_month += ONE_DAY;
}
$start_of_month -= ONE_MONTH; # Subtract one month to get previous month. "ONE_MONTH" is defined by Time::Seconds
$end_of_month = $start_of_month; # Copy start_of_month to end_of_month as they both have same year and month.
# Subtract day from $start_of_month until mday is the first day of the month.
while($start_of_month->mday != 1) {
$start_of_month -= ONE_DAY;
}
# Silly workaround to bring $end_of_month to last day of the month as Time::Piece object does not have good way to change mday.
while($end_of_month->mday != $start_of_month->month_last_day) {
$end_of_month += ONE_DAY;
}
$period_start = $start_of_month->dmy("."); # End result has to be same!
Can anyone give me a better way of handling this?
Don't rely on Time::Piece and constants in Time::Seconds for date manipulation
The following was my suggested simplification of the OP's date manipulation using Time::Piece and Time::Seconds. IF this worked on overloaded operators, it might actually work as intended, but as ikegami pointed out, this isn't guaranteed. So I tested below.
If you want to go the math route, at least you could simplify things a little:
use strict;
use warnings;
use Time::Piece;
use Time::Seconds;
my $date_start = localtime();
$date_start -= ONE_MONTH;
$date_start -= ($date_start->mday - 1) * ONE_DAY;
my $date_end = $date_start + ($date_start->month_last_day - 1) * ONE_DAY;
print $date_start , "\n"; # Prints Mar 1st (at least today it does)
print $date_end , "\n"; # Prints Mar 31st
I'd consider using a different module for this, like Date::Calc or DateTime, but this might work for your purposes.
Testing the above solution - many failures
I created a script the below script that loops through every date for a year starting at January 15th, showing every range where the above code does not work as expected.
use strict;
use warnings;
use Time::Piece;
use Time::Seconds;
my $t = 1389812400; # Wed 2014-Jan-15 7pm GMT. 11am PST
my $t_max = 1421348400; # Thu 2015-Jan-15 7pm GMT. 11am PST
my %prev_month = map {$_ => ($_ - 1) || 12} (1..12);
my $fail = '';
while ($t <= $t_max) {
$t += 60; # Increment by 1 minute
# Testing potentially overloaded math of Time::Piece & Time::Seconds
my $start = my $src = localtime($t);
$start -= ONE_MONTH;
$start -= ($start->mday - 1) * ONE_DAY;
if ($start->mon != $prev_month{$src->mon}) {
print "From ($t) $src -> $start\n" if !$fail;
$fail = " To ($t) $src -> $start\n\n";
} elsif ($fail) {
print $fail;
$fail = '';
}
}
The below is the output of this script with comments inserted to explain why each range fails:
# ONE_MONTH is exactly 2_629_744 seconds, or 30.437 days.
# ONE_MONTH is too short for January
From (1391193000) Fri Jan 31 10:30:00 2014 -> Wed Jan 1 00:00:56 2014
To (1391241540) Fri Jan 31 23:59:00 2014 -> Wed Jan 1 13:29:56 2014
# ONE_MONTH is too long for February
From (1393660800) Sat Mar 1 00:00:00 2014 -> Wed Jan 1 13:30:56 2014
To (1393871340) Mon Mar 3 10:29:00 2014 -> Wed Jan 1 23:59:56 2014
# ONE_MONTH is too short for March
From (1396290600) Mon Mar 31 11:30:00 2014 -> Sat Mar 1 00:00:56 2014
To (1396335540) Mon Mar 31 23:59:00 2014 -> Sat Mar 1 12:29:56 2014
# ONE_DAY is 86_400 seconds, or 24 hours.
# March 9th is only 23 hours long due to DST, ONE_DAY goes to far.
From (1397064600) Wed Apr 9 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397068140) Wed Apr 9 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397151000) Thu Apr 10 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397154540) Thu Apr 10 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397237400) Fri Apr 11 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397240940) Fri Apr 11 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397323800) Sat Apr 12 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397327340) Sat Apr 12 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397410200) Sun Apr 13 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397413740) Sun Apr 13 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397496600) Mon Apr 14 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397500140) Mon Apr 14 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397583000) Tue Apr 15 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397586540) Tue Apr 15 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397669400) Wed Apr 16 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397672940) Wed Apr 16 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397755800) Thu Apr 17 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397759340) Thu Apr 17 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397842200) Fri Apr 18 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397845740) Fri Apr 18 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1397928600) Sat Apr 19 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1397932140) Sat Apr 19 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398015000) Sun Apr 20 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398018540) Sun Apr 20 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398101400) Mon Apr 21 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398104940) Mon Apr 21 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398187800) Tue Apr 22 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398191340) Tue Apr 22 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398274200) Wed Apr 23 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398277740) Wed Apr 23 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398360600) Thu Apr 24 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398364140) Thu Apr 24 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398447000) Fri Apr 25 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398450540) Fri Apr 25 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398533400) Sat Apr 26 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398536940) Sat Apr 26 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398619800) Sun Apr 27 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398623340) Sun Apr 27 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398706200) Mon Apr 28 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398709740) Mon Apr 28 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398792600) Tue Apr 29 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398796140) Tue Apr 29 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
From (1398879000) Wed Apr 30 10:30:00 2014 -> Fri Feb 28 23:00:56 2014
To (1398882540) Wed Apr 30 11:29:00 2014 -> Fri Feb 28 23:59:56 2014
# ONE_MONTH is too long for April
From (1398927600) Thu May 1 00:00:00 2014 -> Sat Mar 1 12:30:56 2014
To (1398965340) Thu May 1 10:29:00 2014 -> Sat Mar 1 22:59:56 2014
# ONE_MONTH is too short for May
From (1401557400) Sat May 31 10:30:00 2014 -> Thu May 1 00:00:56 2014
To (1401605940) Sat May 31 23:59:00 2014 -> Thu May 1 13:29:56 2014
# ONE_MONTH is too long for June
From (1404198000) Tue Jul 1 00:00:00 2014 -> Thu May 1 13:30:56 2014
To (1404235740) Tue Jul 1 10:29:00 2014 -> Thu May 1 23:59:56 2014
# ONE_MONTH is too short for July
From (1406827800) Thu Jul 31 10:30:00 2014 -> Tue Jul 1 00:00:56 2014
To (1406876340) Thu Jul 31 23:59:00 2014 -> Tue Jul 1 13:29:56 2014
# ONE_MONTH is too short for August
From (1409506200) Sun Aug 31 10:30:00 2014 -> Fri Aug 1 00:00:56 2014
To (1409554740) Sun Aug 31 23:59:00 2014 -> Fri Aug 1 13:29:56 2014
# ONE_MONTH is too long for September
From (1412146800) Wed Oct 1 00:00:00 2014 -> Fri Aug 1 13:30:56 2014
To (1412184540) Wed Oct 1 10:29:00 2014 -> Fri Aug 1 23:59:56 2014
# ONE_MONTH is too short for October
From (1414776600) Fri Oct 31 10:30:00 2014 -> Wed Oct 1 00:00:56 2014
To (1414825140) Fri Oct 31 23:59:00 2014 -> Wed Oct 1 13:29:56 2014
# ONE_MONTH is too long for November
From (1417420800) Mon Dec 1 00:00:00 2014 -> Wed Oct 1 14:30:56 2014
To (1417454940) Mon Dec 1 09:29:00 2014 -> Wed Oct 1 23:59:56 2014
# ONE_MONTH is too short for December
From (1420050600) Wed Dec 31 10:30:00 2014 -> Mon Dec 1 00:00:56 2014
To (1420099140) Wed Dec 31 23:59:00 2014 -> Mon Dec 1 13:29:56 2014
Alternative using Time::Piece->add_months? Nope
Time::Piece has two functions, add_months and add_years intended for date calculations. Unfortunately, the documentation states:
Note that there is some "strange" behaviour when adding and subtracting months at the ends of months. Generally when the resulting month is shorter than the starting month then the number of overlap days is added. For example subtracting a month from 2008-03-31 will not result in 2008-02-31 as this is an impossible date. Instead you will get 2008-03-02. This appears to be consistent with other date manipulation tools.
The below code fully demonstrates this behavior for the timezone PST.
use strict;
use warnings;
use Time::Piece;
my $t = localtime(1420012800);
print $t->add_months($_),"\n" for (0..12)
Output:
Wed Dec 31 00:00:00 2014
Sat Jan 31 00:00:00 2015
Tue Mar 3 00:00:00 2015
Tue Mar 31 00:00:00 2015
Fri May 1 00:00:00 2015
Sun May 31 00:00:00 2015
Wed Jul 1 00:00:00 2015
Fri Jul 31 00:00:00 2015
Mon Aug 31 00:00:00 2015
Thu Oct 1 00:00:00 2015
Sat Oct 31 00:00:00 2015
Tue Dec 1 00:00:00 2015
Thu Dec 31 00:00:00 2015
Now, it is kind of nice how this function is able to accurately cycle back to the same date a year later, but there are lots of unfavorable months until then.
Conclusion
The constants in Time::Seconds are just that, constants. They are exact numbers of seconds meant to represent periods of time. There is no operator overloading to facilitate fancy date manipulation. Instead, these values are simply good for mathematical comparisons.
To manipulate specific dates, I'd advise using Date::Calc, DateTime, or any of the other modules suggested in this question.
A less OO, but alternate solution:
use POSIX qw(mktime);
my #now = localtime;
# mday = 1, month = month - 1
my $date_start = mktime(#now[0 .. 2], 1, $now[4] - 1, #now[5 .. 8]);
# mday = 0, the 0th day of this month == last day of prior month
my $date_end = mktime(#now[0 .. 2], 0, #now[4 .. 8]);
print scalar localtime $date_start, "\n";
print scalar localtime $date_end, "\n";
This hiccups with daylight saving time; if you don't care about time-of-day you could set $now[2] to 12 noon and hope no country declares night to be day and day to be night:
my #now = (0, 0, 12, (localtime)[3..8]);
I don't trust code that uses Time::Piece. It relies on overloading operators to make it look like you're doing it wrong ($time += ONE_DAY; looks like you're adding a constant) when you're actually doing it right. Maybe. It's hard to tell. You must have intimate knowledge of the guts of the module to know if you're doing it right.
DateTime solution:
my $dt = DateTime
->now( time_zone => 'local' )
->set_time_zone('floating') # Do this when you want to date arithmetic.
->truncate( to => 'day' );
$dt->set( day => 1 )->subtract( days => 1 );
my $last = $dt->ymd('-');
$dt->set( day => 1 );
my $first = $dt->ymd('-');
say "$first .. $last";
Using the Time::Seconds definition of ONE_MONTH gives you a solution that is wrong for several days a year. It is the average length of a month in seconds, and is equal to about 30.4 days. Subtracting that from 1 March, for instance, gives you a date in late January.
However the first day of the previous month can be calculated simply from the month and day fields returned by localtime. Converting this into a Time::Piece object lets us calculate the last day of the same month.
use strict;
use warnings;
use Time::Piece;
my ($m, $y) = (localtime)[4,5];
$y += 1900;
if ($m == 0) {
$m = 11;
$y -= 1;
}
my $period_start = sprintf '%02d.%02d.%04d', 1, $m, $y;
my $period_end = do {
my $tp = Time::Piece->strptime($period_start, '%d.%m.%Y');
sprintf '%02d.%02d.%04d', $tp->month_last_day, $m, $y;
};
print $period_start, "\n";
print $period_end, "\n";
output
01.03.2014
31.03.2014
Sorry if I did not understood property but: DaysInMonth (check coment)
my #monthDays= qw( 31 28 31 30 31 30 31 31 30 31 30 31 );
sub MonthDays {
my $month= shift(#_);
my $year= #_ ? shift(#_) : 1900+(localtime())[5];
if( $year <= 1752 ) {
# Note: Although September 1752 only had 19 days,
# they were numbered 1,2,14..30!
return 19 if 1752 == $year && 9 == $month;
return 29 if 2 == $month && 0 == $year % 4;
} else {
return 29 if 2 == $month and
0 == $year%4 && 0 != $year%100 || 0 == $year%400;
}
return $monthDays[$month-1];
}
If you wish easy data to seconds then take look Time::Local
$time = timelocal( $sec, $min, $hour, $mday, $mon, $year );