Permalink
Browse files

NCBC-1335: Only run XATTRs and Analytics integration tests when avail…

…able

MOTIVATION
----------
Currently neither XAttributes or Analytics are not supported by the test
cluster that is created for integration tests and always fail. These
tests should only be run when the cluster supports them.

MODIFICATIONS
-------------
- Add SupportsXAttributes property to CouchbaseBucket
- Check if bucket supports XAttributes before running XAttribute tests
- Ignore Analytics tests

RESULT
------
XAttribute integration tests are only run when the test cluster supports
them. Analytics integration tests are ignored until the service can be
discovered.

Change-Id: Id6f14d4a762657eda59a21dac096b2a1cf54e890
Reviewed-on: http://review.couchbase.org/74040
Tested-by: Mike Goldsmith <goldsmith.mike@gmail.com>
Reviewed-by: Jeffry Morris <jeffrymorris@gmail.com>
  • Loading branch information...
MikeGoldsmith committed Feb 21, 2017
1 parent c8160fa commit 3c495189e72525fa29d126da3cfbbfc7909241df
@@ -34,7 +34,7 @@ private class TestRequest
public string Greeting { get; set; }
}
[Test]
[Test, Ignore("Analytics service is not currently discoverable. Until it is, we don't want to run these tests automatically.")]
public void Execute_Query()
{
const string statement = "SELECT \"hello\" as greeting;";
@@ -47,7 +47,7 @@ public void Execute_Query()
Assert.AreEqual("hello", result.Rows.First().Greeting);
}
[Test]
[Test, Ignore("Analytics service is not currently discoverable. Until it is, we don't want to run these tests automatically.")]
public async Task Execute_Query_Async()
{
const string statement = "SELECT \"hello\" as greeting;";
@@ -1171,12 +1171,25 @@ public void LookupIn_Exists(bool useMutation)
#region XATTRs
private const string XAttrsNotSupported = "XATTRs not supported.";
private bool SupportsXAttributes()
{
var bucket = (CouchbaseBucket) _bucket;
return bucket != null && bucket.SupportsSubdocXAttributes;
}
[TestCase(false)]
[TestCase(true)]
public void Can_Create_Get_And_Check_Single_Xattr_Exists(bool useMutation)
{
Setup(useMutation);
if (!SupportsXAttributes())
{
Assert.Ignore(XAttrsNotSupported);
}
const string key = "Can_Create_Get_And_Check_Single_Xattr_Exists";
const string username = "jack";
_bucket.Upsert(key, new {first = "foo", last = "bar"});
@@ -1207,6 +1220,11 @@ public void Can_Create_Get_And_Check_Multiple_Xattrs_Exist(bool useMutation)
{
Setup(useMutation);
if (!SupportsXAttributes())
{
Assert.Ignore(XAttrsNotSupported);
}
const string key = "Can_Create_Get_And_Check_Multiple_Xattrs_Exist";
_bucket.Upsert(key, new {foo = "bar"});
@@ -1243,6 +1261,11 @@ public void XATTRS_Persist_After_Upsert_Or_Replace(bool useMutation)
{
Setup(useMutation);
if (!SupportsXAttributes())
{
Assert.Ignore(XAttrsNotSupported);
}
const string key = "XATTRS_Persist_After_Replace";
const string field = "_data.created_by";
const string value = "jack";
@@ -1277,6 +1300,11 @@ public void Can_Create_XATTR_with_CreatePath_Flag(bool useMutation)
{
Setup(useMutation);
if (!SupportsXAttributes())
{
Assert.Ignore(XAttrsNotSupported);
}
const string key = "Can_Get_XATTR_with_CreatePath_Flag";
const string field = "created_by";
const string value = "jack";
@@ -1303,6 +1331,11 @@ public void Can_Create_Document_With_CreateDocument_Subdoc_Flag(bool useMutation
{
Setup(useMutation);
if (!SupportsXAttributes())
{
Assert.Ignore(XAttrsNotSupported);
}
const string key = "Can_Create_Document_With_CreateDocument_Subdoc_Flag";
const string field = "name";
const string name = "mike";
@@ -1333,6 +1366,11 @@ public void Can_Get_Deleted_Document_System_XATTR_Using_AccessDeleted_Subdoc_Fla
{
Setup(useMutation);
if (!SupportsXAttributes())
{
Assert.Ignore(XAttrsNotSupported);
}
const string key = "Can_Get_Deleted_Document_XATTR_Using_AccessDeleted_Subdoc_Flag";
const string field = "_data.username";
const string value = "jack";
@@ -1364,6 +1402,11 @@ public void Can_Use_Server_Macro_To_Populate_XATTR(bool useMutation)
{
Setup(useMutation);
if (!SupportsXAttributes())
{
Assert.Ignore(XAttrsNotSupported);
}
const string key = "Can_Use_Server_Macro_To_Populate_XATTR";
const string field = "cas";
const string value = "${Mutation.CAS}";
@@ -3491,6 +3491,17 @@ public bool SupportsEnhancedDurability
get { return _configInfo.SupportsEnhancedDurability; }
}
/// <summary>
/// Gets a value indicating whether subdoc operations on xattributes are available.
/// </summary>
/// <value>
/// <c>true</c> if the cluster supports subdoc operations on xattributes; otherwise, <c>false</c>.
/// </value>
internal bool SupportsSubdocXAttributes
{
get { return _configInfo.SupportsSubdocXAttributes; }
}
/// <summary>
/// Invalidates and clears the query cache. This method can be used to explicitly clear the internal N1QL query cache. This cache will
/// be filled with non-adhoc query statements (query plans) to speed up those subsequent executions. Triggering this method will wipe

0 comments on commit 3c49518

Please sign in to comment.