Re: [Spacewalk-devel] [PATCH] Proposal to remove filesystem dependencies from ConfigTest

2013-11-06 Thread Tomas Lestach
> Anyway if you ever come up with a better idea I am always open to
> hear
> it and patch the code again!

Great, thank you! :-)

Regards,
--
Tomas Lestach
Red Hat Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] [PATCH] Proposal to remove filesystem dependencies from ConfigTest

2013-11-06 Thread Silvio Moioli
On 11/06/2013 04:23 PM, Tomas Lestach wrote:
> I am sorry, it took me so long to reply.

No problem.

> Honestly, we do not really like the proposed patch,
> but on the other hand we didn't come with anything better. :-)

Oh, I see :-)

Anyway if you ever come up with a better idea I am always open to hear
it and patch the code again!

Have a nice day,
-- 
Silvio Moioli
SUSE LINUX Products GmbH
Maxfeldstraße 5, 90409 Nürnberg Germany

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] [PATCH] Proposal to remove filesystem dependencies from ConfigTest

2013-11-06 Thread Tomas Lestach
Hello Silvio,

I am sorry, it took me so long to reply.

Honestly, we do not really like the proposed patch,
but on the other hand we didn't come with anything better. :-)

I applied your patch as: dd0b273d4c5863dd42e83499294468be849f4463

Bye,
--
Tomas Lestach
Red Hat Satellite Engineering, Red Hat


- Original Message -
> From: "Silvio Moioli" 
> To: spacewalk-devel@redhat.com
> Sent: Monday, October 21, 2013 1:20:45 PM
> Subject: Re: [Spacewalk-devel] [PATCH] Proposal to remove filesystem  
> dependencies from ConfigTest
> 
> On 10/21/2013 11:57 AM, Tomas Lestach wrote:
> > but if you're running the tests from
> > /usr/share/rhn/lib/rhn-test.jar
> > using the /usr/share/rhn/unittest.xml, you shall have it already
> > installed.
> 
> Our current setup does not (necessarily) run tests on the same host
> where Spacewalk runs, so we make no assumptions over installed
> packages.
> Actually we often run tests using the Eclipse runner, while pointing
> to
> a database on another host by using a special rhn.conf file. In that
> case, development machine where tests are run has no Spacewalk
> package
> at all.
> 
> > What is the reason you'd like have them in /tmp?
> > I suppose the config files are used just for reading, so the
> > current directory
> > might be ok.
> 
> That could work as well, we anyway prefer /tmp not to pollute
> Eclipse's
> project directory with those extracted files since we run tests from
> there (that can be changed, it's just a little bit less convenient
> IMO).
> 
> Regards,
> --
> Silvio Moioli
> SUSE LINUX Products GmbH
> Maxfeldstraße 5, 90409 Nürnberg Germany
> 
> ___
> Spacewalk-devel mailing list
> Spacewalk-devel@redhat.com
> https://www.redhat.com/mailman/listinfo/spacewalk-devel
> 

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Re: [Spacewalk-devel] [PATCH] Proposal to remove filesystem dependencies from ConfigTest

2013-10-21 Thread Silvio Moioli
On 10/21/2013 11:57 AM, Tomas Lestach wrote:
> but if you're running the tests from /usr/share/rhn/lib/rhn-test.jar
> using the /usr/share/rhn/unittest.xml, you shall have it already installed.

Our current setup does not (necessarily) run tests on the same host
where Spacewalk runs, so we make no assumptions over installed packages.
Actually we often run tests using the Eclipse runner, while pointing to
a database on another host by using a special rhn.conf file. In that
case, development machine where tests are run has no Spacewalk package
at all.

> What is the reason you'd like have them in /tmp?
> I suppose the config files are used just for reading, so the current directory
> might be ok.

That could work as well, we anyway prefer /tmp not to pollute Eclipse's
project directory with those extracted files since we run tests from
there (that can be changed, it's just a little bit less convenient IMO).

Regards,
-- 
Silvio Moioli
SUSE LINUX Products GmbH
Maxfeldstraße 5, 90409 Nürnberg Germany

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


Re: [Spacewalk-devel] [PATCH] Proposal to remove filesystem dependencies from ConfigTest

2013-10-21 Thread Tomas Lestach
Hello Silvio,

> ConfigTest at the moment relies on some config files to be in a fixed
> filesystem path (/usr/share/rhn/unit-tests/conf). This can be
> inconvenient because, among other things, writing to /usr requires
> root
> access.

These config files are packaged within spacewalk-java-tests rpm:

# rpm -ql spacewalk-java-tests | grep conf
/usr/share/rhn/unit-tests/conf
/usr/share/rhn/unit-tests/conf/default
/usr/share/rhn/unit-tests/conf/default/bug154517.conf.rpmsave
/usr/share/rhn/unit-tests/conf/default/rhn_prefix.conf
/usr/share/rhn/unit-tests/conf/default/rhn_web.conf
/usr/share/rhn/unit-tests/conf/rhn.conf

but if you're running the tests from /usr/share/rhn/lib/rhn-test.jar
using the /usr/share/rhn/unittest.xml, you shall have it already installed.

> The attached patch proposes a self-contained solution where those
> files
> are taken from either the classes directory or the jar file, copied
> in
> /tmp and read from there.

What is the reason you'd like have them in /tmp?
I suppose the config files are used just for reading, so the current directory
might be ok.


Regards,
--
Tomas Lestach
Red Hat Satellite Engineering, Red Hat

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel


[Spacewalk-devel] [PATCH] Proposal to remove filesystem dependencies from ConfigTest

2013-09-30 Thread Silvio Moioli
Hi,

ConfigTest at the moment relies on some config files to be in a fixed
filesystem path (/usr/share/rhn/unit-tests/conf). This can be
inconvenient because, among other things, writing to /usr requires root
access.

The attached patch proposes a self-contained solution where those files
are taken from either the classes directory or the jar file, copied in
/tmp and read from there.

As there are other possible solutions  I wanted to submit this for
review here before pushing it.

Thanks,
-- 
Silvio Moioli
SUSE LINUX Products GmbH
Maxfeldstraße 5, 90409 Nürnberg Germany
>From f027ba5978cb78f786d344d686172fd0756c835b Mon Sep 17 00:00:00 2001
From: Silvio Moioli 
Date: Mon, 30 Sep 2013 16:29:29 +0200
Subject: [PATCH] ConfigTest: do not rely on hardcoded paths, preexisting files

---
 .../redhat/rhn/common/conf/test/ConfigTest.java| 25 +++---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/java/code/src/com/redhat/rhn/common/conf/test/ConfigTest.java b/java/code/src/com/redhat/rhn/common/conf/test/ConfigTest.java
index 310964d..ab461a9 100644
--- a/java/code/src/com/redhat/rhn/common/conf/test/ConfigTest.java
+++ b/java/code/src/com/redhat/rhn/common/conf/test/ConfigTest.java
@@ -19,19 +19,38 @@ import com.redhat.rhn.common.conf.Config;
 import com.redhat.rhn.testing.RhnBaseTestCase;
 import com.redhat.rhn.testing.TestUtils;
 
+import java.io.File;
 import java.util.Iterator;
 import java.util.Properties;
 
+import org.apache.commons.io.FileUtils;
+
 public class ConfigTest extends RhnBaseTestCase {
 static final String TEST_KEY = "user";
 static final String TEST_VALUE = "newval";
-static final String TEST_CONF_LOCATION = "/usr/share/rhn/unit-tests/conf";
 private Config c;
 
 public void setUp() throws Exception {
 c = new Config();
-c.addPath(TEST_CONF_LOCATION + "/default");
-c.addPath(TEST_CONF_LOCATION);
+
+// create test config path
+String confPath = "/tmp/" + TestUtils.randomString() + "/conf";
+String defaultPath = confPath + "/default";
+new File(defaultPath).mkdirs();
+
+// copy test configuration files over
+FileUtils.copyURLToFile(TestUtils.findTestData("conf/rhn.conf"), new File(confPath,
+"rhn.conf"));
+FileUtils.copyURLToFile(TestUtils.findTestData("conf/default/rhn_web.conf"),
+new File(defaultPath, "rhn_web.conf"));
+FileUtils.copyURLToFile(TestUtils.findTestData("conf/default/rhn_prefix.conf"),
+new File(defaultPath, "rhn_prefix.conf"));
+FileUtils.copyURLToFile(TestUtils
+.findTestData("conf/default/bug154517.conf.rpmsave"),
+new File(defaultPath, "bug154517.conf.rpmsave"));
+
+c.addPath(confPath);
+c.addPath(defaultPath);
 c.parseFiles();
 }
 
-- 
1.8.1.4

___
Spacewalk-devel mailing list
Spacewalk-devel@redhat.com
https://www.redhat.com/mailman/listinfo/spacewalk-devel