Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit b2c210b

Browse files
authored
Merge pull request #50 from gruntwork-io/yori-ubuntu18
Add ubuntu18.04 to examples and test
2 parents 8f6bd85 + 1911abd commit b2c210b

File tree

10 files changed

+150
-63
lines changed

10 files changed

+150
-63
lines changed

examples/couchbase-ami/couchbase.json

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@
2424
"most_recent": true
2525
},
2626
"ssh_username": "ubuntu"
27+
},{
28+
"name": "ubuntu-18-ami",
29+
"ami_name": "{{user `base_ami_name`}}-ubuntu-18-example-{{isotime | clean_ami_name}}",
30+
"ami_description": "An Ubuntu 18.04 AMI that has Couchbase installed.",
31+
"instance_type": "t2.micro",
32+
"region": "{{user `aws_region`}}",
33+
"type": "amazon-ebs",
34+
"source_ami_filter": {
35+
"filters": {
36+
"virtualization-type": "hvm",
37+
"architecture": "x86_64",
38+
"name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
39+
"block-device-mapping.volume-type": "gp2",
40+
"root-device-type": "ebs"
41+
},
42+
"owners": ["099720109477"],
43+
"most_recent": true
44+
},
45+
"ssh_username": "ubuntu"
2746
},{
2847
"name": "amazon-linux-ami",
2948
"ami_name": "{{user `base_ami_name`}}-amazon-linux-example-{{isotime | clean_ami_name}}",
@@ -53,6 +72,16 @@
5372
"volumes": {
5473
"/sys/fs/cgroup": "/sys/fs/cgroup"
5574
}
75+
},{
76+
"name": "ubuntu-18-docker",
77+
"type": "docker",
78+
"image": "gruntwork/ubuntu-test:18.04",
79+
"commit": true,
80+
"run_command": ["-d", "-i", "-t", "{{.Image}}", "/sbin/init"],
81+
"privileged": true,
82+
"volumes": {
83+
"/sys/fs/cgroup": "/sys/fs/cgroup"
84+
}
5685
},{
5786
"name": "amazon-linux-docker",
5887
"type": "docker",
@@ -75,10 +104,10 @@
75104
"type": "shell",
76105
"pause_before": "5s",
77106
"inline": [
78-
"DEBIAN_FRONTEND=noninteractive apt-get update",
79-
"apt-get install -y git"
107+
"apt-get update",
108+
"DEBIAN_FRONTEND=noninteractive apt-get install -y git"
80109
],
81-
"only": ["ubuntu-docker"]
110+
"only": ["ubuntu-docker", "ubuntu-18-docker"]
82111
},{
83112
"type": "shell",
84113
"pause_before": "30s",
@@ -91,11 +120,11 @@
91120
"type": "shell",
92121
"pause_before": "30s",
93122
"inline": [
94-
"DEBIAN_FRONTEND=noninteractive sudo apt-get update",
95-
"sudo apt-get install -y jq curl git python-pip",
123+
"sudo apt-get update",
124+
"sudo DEBIAN_FRONTEND=noninteractive apt-get install -y jq curl git python-pip",
96125
"sudo -H pip install --upgrade awscli"
97126
],
98-
"only": ["ubuntu-ami"]
127+
"only": ["ubuntu-ami", "ubuntu-18-ami"]
99128
},{
100129
"type": "shell",
101130
"inline": [
@@ -126,6 +155,11 @@
126155
"repository": "gruntwork/couchbase-ubuntu-test",
127156
"tag": "latest",
128157
"only": ["ubuntu-docker"]
158+
},{
159+
"type": "docker-tag",
160+
"repository": "gruntwork/couchbase-ubuntu-18-test",
161+
"tag": "latest",
162+
"only": ["ubuntu-18-docker"]
129163
},{
130164
"type": "docker-tag",
131165
"repository": "gruntwork/couchbase-amazon-linux-test",

modules/couchbase-cluster/main.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ resource "aws_iam_instance_profile" "instance_profile" {
162162
lifecycle {
163163
create_before_destroy = true
164164
}
165+
166+
# IAM objects take time to propagate. This leads to subtle eventual consistency bugs where the ASG cannot be created
167+
# because the IAM instance profile does not exist. We add a 15 second wait here to give the IAM instance profile a
168+
# chance to propagate within AWS.
169+
provisioner "local-exec" {
170+
command = "echo 'Sleeping for 15 seconds to wait for IAM instance profile to be created'; sleep 15"
171+
}
165172
}
166173

167174
resource "aws_iam_role" "instance_role" {
@@ -176,6 +183,13 @@ resource "aws_iam_role" "instance_role" {
176183
lifecycle {
177184
create_before_destroy = true
178185
}
186+
187+
# IAM objects take time to propagate. This leads to subtle eventual consistency bugs where the ASG cannot be created
188+
# because the IAM role does not exist. We add a 15 second wait here to give the IAM role a chance to propagate within
189+
# AWS.
190+
provisioner "local-exec" {
191+
command = "echo 'Sleeping for 15 seconds to wait for IAM role to be created'; sleep 15"
192+
}
179193
}
180194

181195
data "aws_iam_policy_document" "instance_role" {

modules/install-couchbase-server/disable-thp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# Short-Description: Disable THP
1010
# Description: disables Transparent Huge Pages (THP) on boot
1111
### END INIT INFO
12-
12+
1313
case $1 in
1414
start)
1515
if [ -d /sys/kernel/mm/transparent_hugepage ]; then
@@ -22,4 +22,4 @@ start)
2222
return 0
2323
fi
2424
;;
25-
esac
25+
esac

modules/install-couchbase-server/install-couchbase-server

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function print_usage {
4545
echo
4646
echo "Usage: install-couchbase-server [options]"
4747
echo
48-
echo "This script can be used to install Couchbase Server and its dependencies. This script has been tested with Ubuntu 16.04 and Amazon Linux 2."
48+
echo "This script can be used to install Couchbase Server and its dependencies. This script has been tested with Ubuntu 16.04, 18.04, and Amazon Linux 2."
4949
echo
5050
echo "Options:"
5151
echo
@@ -65,29 +65,40 @@ function install_couchbase_on_ubuntu {
6565
local readonly version="$2"
6666
local readonly checksum="$3"
6767
local readonly checksum_type="$4"
68+
local readonly ubuntu_version="$(lsb_release -r -s)"
69+
local readonly dpkg_name="couchbase-server.deb"
6870

69-
log_info "Installing Couchbase $version ($edition edition) on Ubuntu"
71+
log_info "Installing Couchbase $version ($edition edition) on Ubuntu $ubuntu_version"
7072

71-
local readonly filepath="couchbase-server-${edition}_${version}-ubuntu16.04_amd64.deb"
73+
local readonly filepath="couchbase-server-${edition}_${version}-ubuntu${ubuntu_version}_amd64.deb"
7274
local readonly url="https://packages.couchbase.com/releases/$version/$filepath"
7375

76+
# NOTE: Couchbase only started publishing Ubuntu 18.04 deb packages for Enterprise edition version 6.0.2, which means
77+
# that the vast majority of Couchbase server builds do not have official deb packages for 18.04. That said, the 16.04
78+
# package has been verified to work, so we will fallback to using that if the 18.04 build is not available.
79+
local readonly fallback_filepath="couchbase-server-${edition}_${version}-ubuntu16.04_amd64.deb"
80+
local readonly fallback_url="https://packages.couchbase.com/releases/$version/$fallback_filepath"
81+
7482
log_info "Installing Couchbase dependencies"
7583
sudo DEBIAN_FRONTEND=noninteractive apt-get update
7684
sudo apt-get install -y python-httplib2
7785

7886
log_info "Downloading Couchbase from $url to $filepath"
79-
curl --location --silent --fail --show-error -O "$url"
87+
if [[ "$(curl --location --silent --fail --show-error -o "$dpkg_name" -w "%{http_code}" "$url")" == "404" ]]; then
88+
log_warn "Failed to get Couchbase from $url. Trying $fallback_url."
89+
curl --location --silent --fail --show-error -o "$dpkg_name" "$fallback_url"
90+
fi
8091

81-
os_validate_checksum "$filepath" "$checksum" "$checksum_type"
92+
os_validate_checksum "$dpkg_name" "$checksum" "$checksum_type"
8293

8394
# Install Couchbase, but configure it to NOT start on boot. This allows the run-couchbase-server script to configure
8495
# Couchbase, including what ports to use, and THEN boot it up.
85-
log_info "Installing Couchbase from $filepath"
86-
sudo INSTALL_DONT_START_SERVER=1 dpkg -i "$filepath"
96+
log_info "Installing Couchbase from $dpkg_name"
97+
sudo INSTALL_DONT_START_SERVER=1 dpkg -i "$dpkg_name"
8798
sudo systemctl disable couchbase-server
8899

89-
log_info "Cleaning up $filepath"
90-
rm -f "$filepath"
100+
log_info "Cleaning up $dpkg_name"
101+
rm -f "$dpkg_name"
91102
}
92103

93104
function install_couchbase_on_amazon_linux {
@@ -136,7 +147,7 @@ function disable_transparent_huge_pages {
136147
elif os_is_amazon_linux; then
137148
sudo chkconfig disable-thp on
138149
else
139-
log_error "This script only supports Ubuntu 16.04 and Amazon Linux 2."
150+
log_error "This script only supports Ubuntu 16.04, 18.04, and Amazon Linux 2."
140151
exit 1
141152
fi
142153
}
@@ -248,7 +259,7 @@ function install {
248259

249260
log_info "Starting Couchbase install..."
250261

251-
if os_is_ubuntu "16.04"; then
262+
if os_is_ubuntu "16.04" || os_is_ubuntu "18.04"; then
252263
install_couchbase_on_ubuntu "$edition" "$version" "$checksum" "$checksum_type"
253264
elif os_is_amazon_linux "2"; then
254265
install_couchbase_on_amazon_linux "$edition" "$version" "$checksum" "$checksum_type"

modules/install-sync-gateway/install-sync-gateway

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function print_usage {
4848
echo
4949
echo "Usage: install-sync-gateway [options]"
5050
echo
51-
echo "This script can be used to install Couchbase Sync Gateway and its dependencies. This script has been tested with Ubuntu 16.04 and Amazon Linux 2."
51+
echo "This script can be used to install Couchbase Sync Gateway and its dependencies. This script has been tested with Ubuntu 16.04, 18.04, and Amazon Linux 2."
5252
echo
5353
echo "Options:"
5454
echo
@@ -257,12 +257,12 @@ function install {
257257

258258
log_info "Starting Sync Gateway install..."
259259

260-
if os_is_ubuntu "16.04"; then
260+
if os_is_ubuntu "16.04" || os_is_ubuntu "18.04"; then
261261
install_sync_gateway_on_ubuntu "$edition" "$version" "$checksum" "$checksum_type"
262262
elif os_is_amazon_linux "2"; then
263263
install_sync_gateway_on_amazon_linux "$edition" "$version" "$checksum" "$checksum_type"
264264
else
265-
log_error "This script only supports Ubuntu 16.04 and Amazon Linux 2."
265+
log_error "This script only supports Ubuntu 16.04, 18.04, and Amazon Linux 2."
266266
exit 1
267267
fi
268268

test/couchbase_multi_cluster_test.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
package test
22

33
import (
4-
"testing"
5-
"path/filepath"
64
"fmt"
7-
"github.com/gruntwork-io/terratest/modules/test-structure"
8-
"github.com/gruntwork-io/terratest/modules/terraform"
9-
"github.com/gruntwork-io/terratest/modules/random"
5+
"path/filepath"
6+
"testing"
7+
108
"github.com/gruntwork-io/terratest/modules/aws"
9+
"github.com/gruntwork-io/terratest/modules/random"
10+
"github.com/gruntwork-io/terratest/modules/terraform"
11+
"github.com/gruntwork-io/terratest/modules/test-structure"
1112
)
1213

1314
const dataNodeClusterVarName = "couchbase_data_node_cluster_name"
1415
const indexQuerySearchClusterVarName = "couchbase_index_query_search_node_cluster_name"
1516
const syncGatewayClusterVarName = "sync_gateway_cluster_name"
1617

17-
func TestIntegrationCouchbaseEnterpriseMultiClusterUbuntu(t *testing.T) {
18+
func TestIntegrationCouchbaseEnterpriseMultiClusterUbuntu16(t *testing.T) {
1819
t.Parallel()
1920
testCouchbaseMultiCluster(t, "ubuntu", "enterprise")
2021
}
2122

23+
func TestIntegrationCouchbaseEnterpriseMultiClusterUbuntu18(t *testing.T) {
24+
t.Parallel()
25+
testCouchbaseMultiCluster(t, "ubuntu-18", "enterprise")
26+
}
27+
2228
func TestIntegrationCouchbaseEnterpriseMultiClusterAmazonLinux(t *testing.T) {
2329
t.Parallel()
2430
testCouchbaseMultiCluster(t, "amazon-linux", "enterprise")
@@ -65,11 +71,11 @@ func testCouchbaseMultiCluster(t *testing.T, osName string, edition string) {
6571

6672
terraformOptions := &terraform.Options{
6773
TerraformDir: couchbaseMultiClusterDir,
68-
Vars: map[string]interface{} {
74+
Vars: map[string]interface{}{
6975
"ami_id": amiId,
7076
dataNodeClusterVarName: formatCouchbaseClusterName("data", uniqueId),
7177
indexQuerySearchClusterVarName: formatCouchbaseClusterName("search", uniqueId),
72-
syncGatewayClusterVarName: formatCouchbaseClusterName("sync", uniqueId),
78+
syncGatewayClusterVarName: formatCouchbaseClusterName("sync", uniqueId),
7379
},
7480
EnvVars: map[string]string{
7581
AWS_DEFAULT_REGION_ENV_VAR: awsRegion,
@@ -96,4 +102,3 @@ func testCouchbaseMultiCluster(t *testing.T, osName string, edition string) {
96102
checkSyncGatewayWorking(t, syncGatewayUrl)
97103
})
98104
}
99-

test/couchbase_multi_datacenter_replication_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ const savedUniqueIdReplica = "UniqueIdReplica"
2626
const providersFile = "providers.tf"
2727
const providersFileBackup = "providers.tf.bak"
2828

29-
func TestIntegrationCouchbaseEnterpriseMultiDataCenterReplicationUbuntu(t *testing.T) {
29+
func TestIntegrationCouchbaseEnterpriseMultiDataCenterReplicationUbuntu16(t *testing.T) {
3030
t.Parallel()
3131
testCouchbaseMultiDataCenterReplication(t, "ubuntu", "enterprise")
3232
}
3333

34+
func TestIntegrationCouchbaseEnterpriseMultiDataCenterReplicationUbuntu18(t *testing.T) {
35+
t.Parallel()
36+
testCouchbaseMultiDataCenterReplication(t, "ubuntu-18", "enterprise")
37+
}
38+
3439
func TestIntegrationCouchbaseEnterpriseMultiDataCenterReplicationAmazonLinux(t *testing.T) {
3540
t.Parallel()
3641
testCouchbaseMultiDataCenterReplication(t, "amazon-linux", "enterprise")

test/couchbase_single_cluster_dns_tls_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ const domainNameForTest = "gruntwork.in"
1616
// filter them down to the real public hosted zone for domainNameForTest.
1717
var domainNameTags = map[string]string{"original": "true"}
1818

19-
func TestIntegrationCouchbaseCommunitySingleClusterDnsTlsUbuntu(t *testing.T) {
19+
func TestIntegrationCouchbaseCommunitySingleClusterDnsTlsUbuntu16(t *testing.T) {
2020
t.Parallel()
2121
testCouchbaseSingleClusterDnsTls(t, "ubuntu", "community")
2222
}
2323

24+
func TestIntegrationCouchbaseCommunitySingleClusterDnsTlsUbuntu18(t *testing.T) {
25+
t.Parallel()
26+
testCouchbaseSingleClusterDnsTls(t, "ubuntu-18", "community")
27+
}
28+
2429
func testCouchbaseSingleClusterDnsTls(t *testing.T, osName string, edition string) {
2530
examplesFolder := test_structure.CopyTerraformFolderToTemp(t, "../", "examples")
2631
couchbaseAmiDir := filepath.Join(examplesFolder, "couchbase-ami")

test/couchbase_single_cluster_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@ import (
1111

1212
const couchbaseClusterVarName = "cluster_name"
1313

14-
func TestIntegrationCouchbaseCommunitySingleClusterUbuntu(t *testing.T) {
14+
func TestIntegrationCouchbaseCommunitySingleClusterUbuntu16(t *testing.T) {
1515
t.Parallel()
1616
testCouchbaseSingleCluster(t, "ubuntu", "community")
1717
}
1818

19+
func TestIntegrationCouchbaseCommunitySingleClusterUbuntu18(t *testing.T) {
20+
t.Parallel()
21+
testCouchbaseSingleCluster(t, "ubuntu-18", "community")
22+
}
23+
1924
func TestIntegrationCouchbaseCommunitySingleClusterAmazonLinux(t *testing.T) {
2025
t.Parallel()
2126
testCouchbaseSingleCluster(t, "amazon-linux", "community")
2227
}
2328

24-
func TestIntegrationCouchbaseEnterpriseSingleClusterUbuntu(t *testing.T) {
29+
func TestIntegrationCouchbaseEnterpriseSingleClusterUbuntu16(t *testing.T) {
2530
t.Parallel()
2631
testCouchbaseSingleCluster(t, "ubuntu", "enterprise")
2732
}
2833

34+
func TestIntegrationCouchbaseEnterpriseSingleClusterUbuntu18(t *testing.T) {
35+
t.Parallel()
36+
testCouchbaseSingleCluster(t, "ubuntu-18", "enterprise")
37+
}
38+
2939
func TestIntegrationCouchbaseEnterpriseSingleClusterAmazonLinux(t *testing.T) {
3040
t.Parallel()
3141
testCouchbaseSingleCluster(t, "amazon-linux", "enterprise")

0 commit comments

Comments
 (0)