testsuite: Use more ansible for setup

This commit is contained in:
Björn Busse 2021-03-08 23:45:28 +01:00
parent 9a3a0f4de2
commit b1e7dac0f9
10 changed files with 67 additions and 58 deletions

1
.gitignore vendored
View File

@ -5,7 +5,6 @@ hbase-protobuf-python/__pycache__/
hbase-protobuf-python/client/
hbase-protobuf-python/server/
bash_unit
tests/hbase
tests/hbase-?.?.?/
tests/hbase-?.?.?-bin.tar.gz
tests/hbase-?.??.?.?-hadoop2-bin.tar.gz

6
tests/hbase-create.yml Normal file
View File

@ -0,0 +1,6 @@
---
- hosts: namenodes
roles:
- hbase

View File

@ -0,0 +1,3 @@
hbase_version: "0.96.1.1"
hbase_archive: "hbase-{{ hbase_version }}-hadoop2-bin.tar.gz"
hbase_archive_url: "https://archive.apache.org/dist/hbase/hbase-{{ hbase_version }}/{{ hbase_archive }}"

View File

@ -38,32 +38,6 @@ EOF
echo "$CONFIG"
}
prepare_hbase() {
if ! [ -f "$HBASE_TEST_SUITE_EXECUTABLE" ]; then
if [ -f "$HBASE_FILE" ]; then
printf "HBase archive exists\n"
if compare_checksum $HBASE_FILE $HBASE_FILE_CKSUM; then
extract_archive $HBASE_FILE $HBASE_VERSION
mv -f "${HBASE_DIR}" hbase
return
else
printf "HBase archive has wrong checksum (%s)\n" "$1"
printf "Execute script again to redownload file\n"
exit 1
fi
fi
printf "Downloading %s\n" "$1"
curl -LO "${1}"
if compare_checksum $HBASE_FILE $HBASE_FILE_CKSUM; then
extract_archive $HBASE_FILE $HBASE_VERSION
mv -f ${HBASE_DIR} hbase
fi
fi
}
check_dependencies
#prepare_hbase ${HBASE_URL}
HBASE_CONFIG=$(create_hbase_config_template)
write_file ${HBASE_CONFIG_TEMPLATE} "${HBASE_CONFIG}"

View File

@ -0,0 +1,29 @@
---
- name: Download HBase archive
get_url:
url: "{{ hbase_archive_url }}"
dest: "{{ script_path }}"
mode: 0600
checksum: sha256:7334e7da0b655ab02cfc64454c3d2e93a4c584efbde2dfd37915b9530d1643f8
delegate_to: localhost
- name: Copy archive
copy:
src: "{{ script_path }}/{{ hbase_file }}"
dest: "/tmp"
remote_src: yes
- name: Extract archive
ansible.builtin.unarchive:
src: "/tmp/{{ hbase_file }}"
dest: "{{ script_path }}"
remote_src: yes
- name: Write config template
ansible.builtin.command:
cmd: "{{ script_path }}/hbase/files/hbase-config.sh"
delegate_to: localhost
- name: Create hbase-site.xml
template: src={{ script_path }}/{{ hbase_config_path }}/hbase-site.xml.j2 dest={{ script_path }}/{{ hbase_config_path }}/hbase-site.xml mode=0700

View File

@ -3,4 +3,3 @@
- hosts: namenodes
roles:
- hdfs

View File

@ -0,0 +1,3 @@
hadoop_version: "2.10.0"
hadoop_archive_file: "hadoop-{{ hadoop_version }}.tar.gz"
hadoop_archive_url: "https://artfiles.org/apache.org/hadoop/common/hadoop-{{ hadoop_version }}}/{{ hadoop_archive_file }}"

View File

@ -114,33 +114,7 @@ EOF
echo "$CONFIG"
}
prepare_hadoop() {
if ! [ -f "$HDFS_TEST_SUITE_EXECUTABLE" ]; then
printf "Setting up Hadoop\n"
if [ -f "$HADOOP_FILE" ]; then
printf "Hadoop archive exists\n"
if compare_checksum $HADOOP_FILE $HADOOP_FILE_CKSUM; then
extract_archive "$HADOOP_FILE" "$HADOOP_VERSION"
mv -f hadoop-$HADOOP_VERSION hadoop/
return
else
printf "Hadoop archive has wrong checksum (%s)\n" "$1"
printf "Execute script again to redownload file\n"
exit 1
fi
fi
printf "Downloading %s\n" "$1"
curl -LO "${1}"
if compare_checksum $HADOOP_FILE $HADOOP_FILE_CKSUM; then
extract_archive "$HADOOP_FILE" "$HADOOP_VERSION"
mv -f hadoop-$HADOOP_VERSION hadoop/
fi
fi
}
check_dependencies
prepare_hadoop ${HADOOP_URL}
HDFS_CONFIG=$(create_hdfs_config_template)
HDFS_CONFIG_CORE=$(create_hdfs_core_config_template)
HDFS_CONFIG_MAPRED=$(create_hdfs_mapred_config_template)

View File

@ -1,9 +1,29 @@
---
- name: Download and extract HDFS archive
ansible.builtin.shell:
cmd: hdfs-setup.sh
chdir: "{{ hadoop_prefix }}"
- name: Download Hadoop archive
get_url:
url: "{{ hadoop_archive_url }}"
dest: "{{ script_path }}"
mode: 0600
checksum: sha256:273d5fa1d479d0bb96759b16cf4cbd6ba3e7f863a0778cbae55ab83417e961f0
delegate_to: localhost
- name: Copy archive
copy:
src: "{{ script_path }}/{{ hadoop_archive }}"
dest: "/tmp"
remote_src: yes
- name: Extract archive
ansible.builtin.unarchive:
src: "/tmp/{{ hadoop_archive }}"
dest: "{{ script_path }}"
remote_src: yes
- name: Write config template
ansible.builtin.command:
cmd: "{{ script_path }}/hdfs/files/hadoop-config.sh"
delegate_to: localhost
- name: Create core-site.xml
template: src={{ hdfs_config_path}}/core-site.xml.j2 dest={{ hdfs_config_path}}/core-site.xml mode=0700

View File

@ -1,4 +1,6 @@
all:
vars:
children:
namenodes:
vars: