I attached an USB drive to my new toy (dreamplug) to see what performance can I expect. Let me share the results:
dreamplug-debian:/mnt/disk# dd if=/dev/zero of=j bs=1024 count=1000000
1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB) copied, 61.06 s, 16.8 MB/s
dreamplug-debian:/mnt/disk# dd if=j of=/dev/null bs=1024 count=1000000
1000000+0 records in
1000000+0 records out
1024000000 bytes (1.0 GB) copied, 37.4651 s, 27.3 MB/s
I think I am happy with these results. The filesystem was reiserfs.
Wednesday, 28 March 2012
Friday, 9 March 2012
Lettuce from jenkins
.../lettuce/terminal.py", line 82, in get_terminal_size_unix return int(cr[1]), int(cr[0]) TypeError: int() argument must be a string or a number, not 'NoneType'
Anyhow, it seems, that it has already been fixed:
Send flash message from spring security
When I log in, I want to see a flash message, saying "Successful login"
So as you hit the login page, you are served by the secutity filter, and according to the PRG pattern, you will be redirected to the page originally requested. I extended spring's SavedRequestAwareAuthenticationSuccessHandler so that it will ask a SessionFlashMapManager to populate the flash message to the session.
On My context xml:
<bean class="somepackage.AuthenticationSuccessHandler" name="authSucc">
<property name="messageKey" value="flashmessage"/>
<property name="message" value="flashmessage.afterlogin"/>
</bean>
...
<security:http auto-config="true" use-expressions="true">
...
<security:form-login login-page='/login' authentication-success-handler-ref="authSucc"/>
...
</security:http>
You have to define the value in your messages.properties:
flashmessage.afterlogin=Successful login
And its implementation is:
package somepackage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.web.servlet.FlashMap;
import org.springframework.web.servlet.support.SessionFlashMapManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Created by matelakat at 3/9/12 7:44 PM
*/
public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
final Logger logger = LoggerFactory.getLogger(AuthenticationSuccessHandler.class);
private ApplicationContext applicationContext;
private String messageKey;
private String message;
@Autowired
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
public String getMessageKey() {
return messageKey;
}
public void setMessageKey(String messageKey) {
this.messageKey = messageKey;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws ServletException, IOException {
SessionFlashMapManager sessionFlashMapManager = new SessionFlashMapManager();
FlashMap fm = new FlashMap();
fm.put(getMessageKey(), getMessage());
sessionFlashMapManager.saveOutputFlashMap(fm, request, response);
super.onAuthenticationSuccess(request, response, authentication);
}
}
On my freemarker template:
<#import "spring.ftl" as spring>
<#if flashmessage??>
<div id="message"><@spring.message flashmessage/></div>
</#if>
So as you hit the login page, you are served by the secutity filter, and according to the PRG pattern, you will be redirected to the page originally requested. I extended spring's SavedRequestAwareAuthenticationSuccessHandler so that it will ask a SessionFlashMapManager to populate the flash message to the session.
On My context xml:
<bean class="somepackage.AuthenticationSuccessHandler" name="authSucc">
<property name="messageKey" value="flashmessage"/>
<property name="message" value="flashmessage.afterlogin"/>
</bean>
...
<security:http auto-config="true" use-expressions="true">
...
<security:form-login login-page='/login' authentication-success-handler-ref="authSucc"/>
...
</security:http>
You have to define the value in your messages.properties:
flashmessage.afterlogin=Successful login
And its implementation is:
package somepackage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.web.servlet.FlashMap;
import org.springframework.web.servlet.support.SessionFlashMapManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* Created by matelakat at 3/9/12 7:44 PM
*/
public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {
final Logger logger = LoggerFactory.getLogger(AuthenticationSuccessHandler.class);
private ApplicationContext applicationContext;
private String messageKey;
private String message;
@Autowired
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
public String getMessageKey() {
return messageKey;
}
public void setMessageKey(String messageKey) {
this.messageKey = messageKey;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
Authentication authentication) throws ServletException, IOException {
SessionFlashMapManager sessionFlashMapManager = new SessionFlashMapManager();
FlashMap fm = new FlashMap();
fm.put(getMessageKey(), getMessage());
sessionFlashMapManager.saveOutputFlashMap(fm, request, response);
super.onAuthenticationSuccess(request, response, authentication);
}
}
On my freemarker template:
<#import "spring.ftl" as spring>
<#if flashmessage??>
<div id="message"><@spring.message flashmessage/></div>
</#if>
Sunday, 4 March 2012
Blink Thinkpad's light as a user
I want to get some feedback from my local jenkins instance, so I decided to ask Jenkins to blink my thinkpad's keyboard light.
I can control the light as root
# echo 255 > /sys/class/leds/tpacpi\:\:thinklight/brightness
# echo 0 > /sys/class/leds/tpacpi\:\:thinklight/brightness
But my Jenkins is running with a root account. This is where udev comes to play.
# udevadm info -q all -p /sys/devices/platform/thinkpad_acpi/leds/tpacpi\:\:thinklight/
P: /devices/platform/thinkpad_acpi/leds/tpacpi::thinklight
E: UDEV_LOG=3
E: DEVPATH=/devices/platform/thinkpad_acpi/leds/tpacpi::thinklight
E: SUBSYSTEM=leds
I tried to do it with the MODE keyword - FAIL:
# cat /etc/udev/rules.d/80-thinklight.rules
SUBSYSTEM=="leds", MODE="0666"
For some reason it did not set the permissions. I think some concepts are not clear enough for me.
So I went on another route, created a shell script to manipulate the permissions
$ cat /sbin/led.sh
/bin/chmod o+w /sys/devices/platform/thinkpad_acpi/leds/tpacpi\:\:thinklight/brightness
And run it from udev:
$ cat /etc/udev/rules.d/99-thinklight.rules
SUBSYSTEM=="leds", RUN+="/bin/sh /sbin/led.sh"
Ugly, but WORKS
I can control the light as root
# echo 255 > /sys/class/leds/tpacpi\:\:thinklight/brightness
# echo 0 > /sys/class/leds/tpacpi\:\:thinklight/brightness
But my Jenkins is running with a root account. This is where udev comes to play.
# udevadm info -q all -p /sys/devices/platform/thinkpad_acpi/leds/tpacpi\:\:thinklight/
P: /devices/platform/thinkpad_acpi/leds/tpacpi::thinklight
E: UDEV_LOG=3
E: DEVPATH=/devices/platform/thinkpad_acpi/leds/tpacpi::thinklight
E: SUBSYSTEM=leds
I tried to do it with the MODE keyword - FAIL:
# cat /etc/udev/rules.d/80-thinklight.rules
SUBSYSTEM=="leds", MODE="0666"
For some reason it did not set the permissions. I think some concepts are not clear enough for me.
So I went on another route, created a shell script to manipulate the permissions
$ cat /sbin/led.sh
/bin/chmod o+w /sys/devices/platform/thinkpad_acpi/leds/tpacpi\:\:thinklight/brightness
And run it from udev:
$ cat /etc/udev/rules.d/99-thinklight.rules
SUBSYSTEM=="leds", RUN+="/bin/sh /sbin/led.sh"
Ugly, but WORKS
Labels:
brightness,
jenkins,
permissions,
thinklight,
thinkpad,
udev
Saturday, 3 March 2012
Lettuce and IPython interactive shell
Just doing the stuff with mechanize. At some point, it would be great to get an IPython console. so Why not?
@step(u'And give me IPython') def and_continue_here(step): import IPython import sys shell = IPython.InteractiveShell() ip = IPython.core.ipapi.get() p = IPython.core.debugger.Pdb(ip.colors) p.reset() p.interaction(sys._getframe(0), None)
Friday, 2 March 2012
Javascript headless testing
Just a note, so that I won't forget. Use rhino and EnvJs to run jQuery code without a browser. In this way I would be able to test Unobtrusive Javascript code, to see it finds all elements on a rendered page.
BDD testdrive
I gave a try to BDD: looks really good. Fluent textual assertions. I tried out Lettuce. Fine vi syntax highlight stolen from the Cucumber project, see here: gvim syntax file for Gherkin. These are "heavy" functional tests, accessing the depolyed application. Mechanize was used to act as a browser. While I tried to write some assertions, I thought I need the power of jQuery. I asked an old friend of mine, PyQuery to help me. All the stuff was put together very quickly. Ask lettuce to create xUnit output, set up a Jenkins job, run after application deploy - I really like it.
Subscribe to:
Posts (Atom)