Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ jobs:

strategy:
matrix:
server:
- 8.0.0-3716
- 7.6.7
- 7.2.7
- 7.1.6
- 7.0.4

server: [ 8.0.0, 7.6.7, 7.2.7, 7.1.6, 7.0.4, community-8.0.0 ]
include:
- server: community-8.0.0
rcbserverVersion: 8.0.0-community

runs-on: ubuntu-latest
steps:
- name: Install cbdinocluster
run: |
mkdir -p "$HOME/bin"
wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.41/cbdinocluster-linux-amd64
wget -nv -O $HOME/bin/cbdinocluster https://github.com/couchbaselabs/cbdinocluster/releases/download/v0.0.89/cbdinocluster-linux-amd64
chmod +x $HOME/bin/cbdinocluster
echo "$HOME/bin" >> $GITHUB_PATH

Expand All @@ -50,12 +48,20 @@ jobs:
CBDC_ID=$(cbdinocluster -v alloc --def="${CLUSTERCONFIG}")
cbdinocluster -v buckets add ${CBDC_ID} default --ram-quota-mb=100 --flush-enabled=true --num-replicas=2
cbdinocluster -v collections add ${CBDC_ID} default _default test
CBDC_CONNSTR=$(cbdinocluster -v connstr --tls $CBDC_ID)
CBDC_IP=$(cbdinocluster -v ip $CBDC_ID)
echo "CBDC_ID=$CBDC_ID" >> "$GITHUB_ENV"
echo "CBDC_CONNSTR=$CBDC_CONNSTR" >> "$GITHUB_ENV"
echo "CBDC_IP=$CBDC_IP" >> "$GITHUB_ENV"

- name: Set connection string
run: |
if [[ "${{ matrix.server }}" == community* ]]; then
CBDC_CONNSTR=$(cbdinocluster -v connstr $CBDC_ID)
else
CBDC_CONNSTR=$(cbdinocluster -v connstr --tls $CBDC_ID)
fi

echo "CBDC_CONNSTR=$CBDC_CONNSTR" >> "$GITHUB_ENV"

- name: Create fts index
run: |
curl -XPUT -H "Content-Type: application/json" -u Administrator:password http://${{ env.CBDC_IP }}:8094/api/index/basic_search_index -d '{"type": "fulltext-index","name": "basic_search_index","sourceType": "gocbcore","sourceName": "default","planParams": {"maxPartitionsPerPIndex": 1024,"indexPartitions": 1},"params": {"doc_config": {"docid_prefix_delim": "","docid_regexp": "","mode": "type_field","type_field": "type"},"mapping": {"analysis": {},"default_analyzer": "standard","default_datetime_parser": "dateTimeOptional","default_field": "_all","default_mapping": {"dynamic": true,"enabled": true},"default_type": "_default","docvalues_dynamic": true,"index_dynamic": true,"store_dynamic": true,"type_field": "_type"},"store": {"indexType": "scorch","segmentVersion": 15}},"sourceParams": {}}'
Expand All @@ -72,8 +78,13 @@ jobs:
CBDC_CONNSTR: # from above
RCBDINOID: ${{ env.CBDC_ID }}
RCBCONNSTR: ${{ env.CBDC_CONNSTR }}
RCBSERVER_VERSION: ${{ matrix.server }}
run: |
if [[ -z "${{ matrix.rcbserverVersion }}" ]]; then
export RCBSERVER_VERSION=${{ matrix.server }}
else
export RCBSERVER_VERSION=${{ matrix.rcbserverVersion }}
fi

cargo test --color=always --no-fail-fast -- --nocapture

- name: Run allocation tests
Expand All @@ -83,8 +94,13 @@ jobs:
CBDC_CONNSTR: # from above
RCBDINOID: ${{ env.CBDC_ID }}
RCBCONNSTR: ${{ env.CBDC_CONNSTR }}
RCBSERVER_VERSION: ${{ matrix.server }}
run: |
if [[ -z "${{ matrix.rcbserverVersion }}" ]]; then
export RCBSERVER_VERSION=${{ matrix.server }}
else
export RCBSERVER_VERSION=${{ matrix.rcbserverVersion }}
fi

cargo test --features dhat-heap --test allocations --color=always --no-fail-fast -- --nocapture

# - name: Collect couchbase logs
Expand Down
20 changes: 0 additions & 20 deletions sdk/couchbase-core/src/agent_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,6 @@ impl Agent {
&self,
opts: &CreateCollectionOptions<'_>,
) -> Result<CreateCollectionResponse> {
if opts.history_enabled.is_some() {
return self.run_with_bucket_feature_check(
BucketFeature::NonDedupedHistory,
|| async {
self.inner.mgmt.create_collection(opts).await
},
"History retention is not supported - note that the Magma storage engine must be used",
).await;
}

self.inner.mgmt.create_collection(opts).await
}

Expand All @@ -298,16 +288,6 @@ impl Agent {
&self,
opts: &UpdateCollectionOptions<'_>,
) -> Result<UpdateCollectionResponse> {
if opts.history_enabled.is_some() {
return self.run_with_bucket_feature_check(
BucketFeature::NonDedupedHistory,
|| async {
self.inner.mgmt.update_collection(opts).await
},
"History retention is not supported - note that the Magma storage engine must be used",
)
.await;
}
self.inner.mgmt.update_collection(opts).await
}

Expand Down
9 changes: 3 additions & 6 deletions sdk/couchbase-core/src/memdx/datatype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@
* * limitations under the License.
*
*/
use std::convert::From;

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
#[derive(Default)]
pub enum DataTypeFlag {
#[default]
None,
Json,
Compressed,
Xattrs,
}

impl Default for DataTypeFlag {
fn default() -> Self {
Self::None
}
}

impl From<DataTypeFlag> for u8 {
fn from(value: DataTypeFlag) -> Self {
match value {
Expand Down
31 changes: 27 additions & 4 deletions sdk/couchbase-core/tests/common/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
*/

use crate::common::node_version::NodeVersion;
use crate::common::node_version::{NodeEdition, NodeVersion};
use crate::common::test_agent::TestAgent;

const SERVER_VERSION_720: NodeVersion = NodeVersion {
Expand Down Expand Up @@ -46,6 +46,15 @@ const SERVER_VERSION_762: NodeVersion = NodeVersion {
modifier: None,
};

const SERVER_VERSION_800_COMMUNITY: NodeVersion = NodeVersion {
major: 8,
minor: 0,
patch: 0,
build: 0,
edition: Some(NodeEdition::Community),
modifier: None,
};

#[derive(Debug, PartialEq, Eq, Hash)]
pub enum TestFeatureCode {
KV,
Expand All @@ -55,9 +64,11 @@ pub enum TestFeatureCode {
SearchManagement,
SearchManagementCollections,
BucketManagement,
CollectionNoExpiry,
CollectionMaxExpiry,
CollectionUpdates,
HistoryRetention,
UserGroups,
UsersMB69096,
}

impl TestAgent {
Expand All @@ -72,12 +83,24 @@ impl TestAgent {
TestFeatureCode::SearchManagementCollections => {
!self.cluster_version.lower(&SERVER_VERSION_762)
}
TestFeatureCode::CollectionNoExpiry => !self.cluster_version.lower(&SERVER_VERSION_762),
TestFeatureCode::CollectionMaxExpiry => {
self.cluster_version.edition != Some(NodeEdition::Community)
&& !self.cluster_version.lower(&SERVER_VERSION_762)
}
TestFeatureCode::CollectionUpdates => {
!self.cluster_version.lower(&SERVER_VERSION_722)
&& !self.cluster_version.equal(&SERVER_VERSION_722)
}
TestFeatureCode::HistoryRetention => !self.cluster_version.lower(&SERVER_VERSION_720),
TestFeatureCode::HistoryRetention => {
self.cluster_version.edition != Some(NodeEdition::Community)
&& !self.cluster_version.lower(&SERVER_VERSION_720)
}
TestFeatureCode::UserGroups => {
self.cluster_version.edition != Some(NodeEdition::Community)
}
TestFeatureCode::UsersMB69096 => {
!self.cluster_version.equal(&SERVER_VERSION_800_COMMUNITY)
}
}
}
}
15 changes: 11 additions & 4 deletions sdk/couchbase-core/tests/common/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*/

use crate::common::node_version::{NodeEdition, NodeVersion};
use crate::common::test_agent::TestAgent;
use couchbase_core::agent::Agent;
use couchbase_core::error::{Error, ErrorKind};
Expand Down Expand Up @@ -262,13 +263,19 @@ where
timeout_at(deadline, f).await.unwrap()
}

pub async fn run_with_std_kv_deadline<Resp, Fut>(f: Fut) -> Result<Resp, Error>
pub async fn run_with_std_kv_deadline<Resp, Fut>(
node_version: &NodeVersion,
f: Fut,
) -> Result<Resp, Error>
where
Fut: std::future::Future<Output = Result<Resp, Error>>,
{
timeout_at(Instant::now().add(Duration::from_millis(2500)), f)
.await
.unwrap()
let timeout = match node_version.edition {
Some(NodeEdition::Community) => Duration::from_millis(10000),
_ => Duration::from_millis(2500),
};

timeout_at(Instant::now().add(timeout), f).await.unwrap()
}

pub async fn run_with_std_mgmt_deadline<Resp, Fut>(f: Fut) -> Result<Resp, Error>
Expand Down
34 changes: 17 additions & 17 deletions sdk/couchbase-core/tests/common/test_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,74 +82,74 @@ impl TestAgent {
}

pub async fn upsert(&self, opts: UpsertOptions<'_>) -> Result<UpsertResult> {
run_with_std_kv_deadline(self.agent.upsert(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.upsert(opts)).await
}

pub async fn get(&self, opts: GetOptions<'_>) -> Result<GetResult> {
run_with_std_kv_deadline(self.agent.get(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.get(opts)).await
}

pub async fn get_meta(&self, opts: GetMetaOptions<'_>) -> Result<GetMetaResult> {
run_with_std_kv_deadline(self.agent.get_meta(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.get_meta(opts)).await
}

pub async fn delete(&self, opts: DeleteOptions<'_>) -> Result<DeleteResult> {
run_with_std_kv_deadline(self.agent.delete(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.delete(opts)).await
}

pub async fn get_and_lock(&self, opts: GetAndLockOptions<'_>) -> Result<GetAndLockResult> {
run_with_std_kv_deadline(self.agent.get_and_lock(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.get_and_lock(opts)).await
}

pub async fn get_and_touch(&self, opts: GetAndTouchOptions<'_>) -> Result<GetAndTouchResult> {
run_with_std_kv_deadline(self.agent.get_and_touch(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.get_and_touch(opts)).await
}

pub async fn unlock(&self, opts: UnlockOptions<'_>) -> Result<UnlockResult> {
run_with_std_kv_deadline(self.agent.unlock(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.unlock(opts)).await
}

pub async fn touch(&self, opts: TouchOptions<'_>) -> Result<TouchResult> {
run_with_std_kv_deadline(self.agent.touch(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.touch(opts)).await
}

pub async fn add(&self, opts: AddOptions<'_>) -> Result<AddResult> {
run_with_std_kv_deadline(self.agent.add(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.add(opts)).await
}

pub async fn replace(&self, opts: ReplaceOptions<'_>) -> Result<ReplaceResult> {
run_with_std_kv_deadline(self.agent.replace(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.replace(opts)).await
}

pub async fn append(&self, opts: AppendOptions<'_>) -> Result<AppendResult> {
run_with_std_kv_deadline(self.agent.append(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.append(opts)).await
}

pub async fn prepend(&self, opts: PrependOptions<'_>) -> Result<PrependResult> {
run_with_std_kv_deadline(self.agent.prepend(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.prepend(opts)).await
}

pub async fn increment(&self, opts: IncrementOptions<'_>) -> Result<IncrementResult> {
run_with_std_kv_deadline(self.agent.increment(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.increment(opts)).await
}

pub async fn decrement(&self, opts: DecrementOptions<'_>) -> Result<DecrementResult> {
run_with_std_kv_deadline(self.agent.decrement(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.decrement(opts)).await
}

pub async fn get_collection_id(
&self,
opts: GetCollectionIdOptions<'_>,
) -> Result<GetCollectionIdResult> {
run_with_std_kv_deadline(self.agent.get_collection_id(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.get_collection_id(opts)).await
}

pub async fn lookup_in(&self, opts: LookupInOptions<'_>) -> Result<LookupInResult> {
run_with_std_kv_deadline(self.agent.lookup_in(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.lookup_in(opts)).await
}

pub async fn mutate_in(&self, opts: MutateInOptions<'_>) -> Result<MutateInResult> {
run_with_std_kv_deadline(self.agent.mutate_in(opts)).await
run_with_std_kv_deadline(&self.cluster_version, self.agent.mutate_in(opts)).await
}

pub async fn query(&self, opts: QueryOptions) -> Result<QueryResultStream> {
Expand Down
2 changes: 1 addition & 1 deletion sdk/couchbase-core/tests/common/test_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct EnvTestConfig {
pub username: String,
#[envconfig(from = "RCBPASSWORD", default = "password")]
pub password: String,
#[envconfig(from = "RCBCONNSTR", default = "couchbases://192.168.107.128")]
#[envconfig(from = "RCBCONNSTR", default = "couchbase://192.168.107.132")]
pub conn_string: String,
#[envconfig(from = "RCBBUCKET", default = "default")]
pub default_bucket: String,
Expand Down
4 changes: 2 additions & 2 deletions sdk/couchbase-core/tests/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ fn test_ping() {
run_test(async |mut agent| {
let opts = PingOptions::new()
.kv_timeout(Duration::from_millis(1000))
.query_timeout(Duration::from_millis(1000))
.search_timeout(Duration::from_millis(1000));
.query_timeout(Duration::from_millis(75000))
.search_timeout(Duration::from_millis(75000));

let report = agent.ping(&opts).await.unwrap();

Expand Down
Loading