Skip to content

Commit 0d2284e

Browse files
committed
updt tests, docker and def py interpreter to 3
1 parent 91abd2f commit 0d2284e

File tree

7 files changed

+354
-133
lines changed

7 files changed

+354
-133
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,26 @@ ENV CQLSHRC_HOME=$AWS_KEYSPACES_WORKING_DIR/.cassandra
99

1010
WORKDIR $AWS_KEYSPACES_WORKING_DIR
1111

12+
#Install python3 and set as python3 simlink
13+
14+
RUN yum install gcc openssl-devel bzip2-devel libffi-devel gzip make tar -y
15+
RUN curl https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz --output Python-3.7.9.tgz
16+
RUN tar xzf Python-3.7.9.tgz
17+
WORKDIR $AWS_KEYSPACES_WORKING_DIR/Python-3.7.9
18+
RUN ./configure --enable-optimizations
19+
RUN make altinstall
20+
RUN export PATH=${PATH}:/usr/local/lib/
21+
RUN ln -s /usr/local/bin/python3.7 /usr/bin/python3
22+
WORKDIR $AWS_KEYSPACES_WORKING_DIR
23+
RUN rm -f Python-3.7.9.tgz
24+
1225
#Install jq
1326
RUN yum install -y jq && yum clean all
1427

28+
#set as python3 as default interpreter
29+
RUN unlink /usr/bin/python
30+
RUN ln -s /usr/bin/python3 /usr/bin/python
31+
1532
#setup directory structure
1633
RUN mkdir $CASSANDRA_HOME && \
1734
mkdir $CASSANDRA_HOME/bin && \

bin/aws-sm-cqlsh-expo-backoff.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ backoff=0
2323

2424
trap "echo Exited!; exit;" SIGINT SIGTERM
2525

26-
mysecret=$(aws secretsmanager get-secret-value --secret-id "$1" --query SecretString --output text)
26+
mysecret=$(aws secretsmanager get-secret-value --secret-id "$1" --region "$4" --query SecretString --output text)
2727

2828
username=$(jq --raw-output '.username' <<< $mysecret)
2929
password=$(jq --raw-output '.password' <<< $mysecret)
3030
host=$(jq --raw-output '.host' <<< $mysecret)
3131
port=$(jq --raw-output '.port' <<< $mysecret)
3232

33-
echo "cqlsh $host $port -u **** -p **** ${@:4}"
33+
echo "cqlsh-expansion $host $port -u **** -p **** ${@:5}"
3434

3535
while [ $success -ne 0 -a $attempts -le $3 -a $SECONDS -le $2 ]
3636
do
@@ -43,7 +43,7 @@ while [ $success -ne 0 -a $attempts -le $3 -a $SECONDS -le $2 ]
4343
echo ""
4444

4545
#take paramters starting at $4
46-
cqlsh $host $port -u $username -p $password "${@:4}"
46+
cqlsh-expansion $host $port -u $username -p $password "${@:5}"
4747

4848
success=$?
4949
((attempts++))

bin/aws-sm-cqlsh.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
#$1 secret-id
1515
#$2 CQL statement
1616

17-
mysecret=$(aws secretsmanager get-secret-value --secret-id "$1" --query SecretString --output text)
17+
mysecret=$(aws secretsmanager get-secret-value --secret-id "$1" --region "$2" --query SecretString --output text)
1818

1919
username=$(jq --raw-output '.username' <<< $mysecret)
2020
password=$(jq --raw-output '.password' <<< $mysecret)
2121
host=$(jq --raw-output '.host' <<< $mysecret)
2222
port=$(jq --raw-output '.port' <<< $mysecret)
2323

24-
echo "executing.. cqlsh" $host $port "-u *** -p *** ${@:2}"
25-
cqlsh $host $port -u $username -p $password "${@:2}"
24+
echo "executing.. cqlsh" $host $port "-u *** -p *** ${@:3}"
25+
cqlsh-expansion $host $port -u $username -p $password "${@:3}"

cqlsh-expansion/bin/cqlsh-expansion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def find_zip(libprefix):
114114
sys.path.insert(0, os.path.join(cql_zip, 'cassandra-driver-' + ver))
115115

116116
# the driver needs dependencies
117-
third_parties = ('six-', 'pure_sasl-')
117+
third_parties = ('six-', 'pure_sasl-', 'futures-', 'cassandra_sigv4-', 'boto3-', 'botocore-', 'python_dateutil-', 'urllib3-', 'jmespath-')
118118

119119
for lib in third_parties:
120120
lib_zip = find_zip(lib)

cqlsh-expansion/pylib/cqlshlib/legacydesc3x.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def describe_keyspaces_3x(self):
9090
print('')
9191

9292
def describe_keyspace_3x(self, ksname):
93-
print('calling print_recreate')
9493
print_recreate_keyspace(self, self.get_keyspace_meta(ksname), sys.stdout)
9594
print
9695

docker/test/default_cqlshrc

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
; Licensed to the Apache Software Foundation (ASF) under one
2+
; or more contributor license agreements. See the NOTICE file
3+
; distributed with this work for additional information
4+
; regarding copyright ownership. The ASF licenses this file
5+
; to you under the Apache License, Version 2.0 (the
6+
; "License"); you may not use this file except in compliance
7+
; with the License. You may obtain a copy of the License at
8+
;
9+
; http://www.apache.org/licenses/LICENSE-2.0
10+
;
11+
; Unless required by applicable law or agreed to in writing,
12+
; software distributed under the License is distributed on an
13+
; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
; KIND, either express or implied. See the License for the
15+
; specific language governing permissions and limitations
16+
; under the License.
17+
;
18+
; Sample ~/.cqlshrc file.
19+
20+
[authentication]
21+
;; If Cassandra has auth enabled, fill out these options
22+
;; Path to the credentials file, an initial ~ or ~user is expanded to that user's home directory
23+
; credentials = ~/.cassandra/credentials
24+
; keyspace = ks1
25+
26+
[auth_provider]
27+
;; you can specify any auth provider found in your python environment
28+
;; module and class will be used to dynamically load the class
29+
;; all other properties found here and in the credentials file under the class name
30+
;; will be passed to the constructor
31+
module = cassandra.auth
32+
classname = PlainTextAuthProvider
33+
34+
[ui]
35+
;; Whether or not to display query results with colors
36+
; color = on
37+
38+
;; Used for displaying timestamps (and reading them with COPY)
39+
; time_format = %Y-%m-%d %H:%M:%S%z
40+
41+
;; Display timezone
42+
;timezone = Etc/UTC
43+
44+
;; The number of digits displayed after the decimal point for single and double precision numbers
45+
;; (note that increasing this to large numbers can result in unusual values)
46+
;float_precision = 5
47+
;double_precision = 12
48+
49+
;; Used for automatic completion and suggestions
50+
; completekey = tab
51+
52+
;; The encoding used for characters
53+
; encoding = utf8
54+
55+
; To use another than the system default browser for cqlsh HELP to open
56+
; the CQL doc HTML, use the 'browser' preference.
57+
; If the field value is empty or not specified, cqlsh will use the
58+
; default browser (specifying 'browser = default' does not work).
59+
;
60+
; Supported browsers are those supported by the Python webbrowser module.
61+
; (https://docs.python.org/3/library/webbrowser.html).
62+
;
63+
; Hint: to use Google Chome, use
64+
; 'browser = open -a /Applications/Google\ Chrome.app %s' on Mac OS X and
65+
; 'browser = /usr/bin/google-chrome-stable %s' on Linux and
66+
; 'browser = C:/Program Files (x86)/Google/Chrome/Application/chrome.exe %s' on Windows.
67+
;
68+
; This setting can be overridden with the --browser command line option.
69+
;
70+
;browser =
71+
72+
[cql]
73+
;; A version of CQL to use (this should almost never be set)
74+
; version = 3.2.1
75+
76+
77+
78+
[connection]
79+
80+
;; The host to connect to
81+
hostname = 127.0.0.1
82+
83+
;; The port to connect to (9042 is the native protocol default)
84+
port = 9142
85+
86+
;; Always connect using SSL - false by default
87+
ssl = true
88+
89+
;; A timeout in seconds for opening new connections
90+
; timeout = 10
91+
92+
;; A timeout in seconds for executing queries
93+
; request_timeout = 10
94+
95+
96+
97+
[csv]
98+
;; The size limit for parsed fields
99+
field_size_limit = 999999
100+
101+
102+
103+
[tracing]
104+
;; The max number of seconds to wait for a trace to complete
105+
; max_trace_wait = 10.0
106+
107+
108+
109+
[ssl]
110+
certfile = ~/.cassandra/sf-class2-root.crt
111+
112+
;; Optional - true by default.
113+
;validate = true
114+
115+
;; To be provided when require_client_auth=true
116+
;userkey = ~/key.pem
117+
118+
;; To be provided when require_client_auth=true
119+
;usercert = ~/cert.pem
120+
121+
; this is effectively ignored from 4.1 included as TLS protocol is auto-negotiated and will
122+
; be removed in the next major version of Cassandra, possible values were TLSv1, TLSv1_1 or TLSv1_2
123+
;version = TLSv1_2
124+
125+
;; Optional section, overrides default certfile in [ssl] section, if present
126+
; [certfiles]
127+
; 192.168.1.3 = ~/keys/cassandra01.cert
128+
; 192.168.1.4 = ~/keys/cassandra02.cert
129+
130+
131+
132+
;; Options that are common to both COPY TO and COPY FROM
133+
[copy]
134+
135+
;; The string placeholder for null values
136+
; nullval = null
137+
138+
;; For COPY TO, controls whether the first line in the CSV output file will
139+
;; contain the column names. For COPY FROM, specifies whether the first
140+
;; line in the CSV file contains column names.
141+
; header = false
142+
143+
;; The character that is used as the decimal point separator
144+
; decimalsep = .
145+
146+
;; The character that is used to separate thousands
147+
;; (defaults to the empty string)
148+
; thousandssep =
149+
150+
;; The string literal format for boolean values
151+
; boolstyle = True,False
152+
153+
;; The number of child worker processes to create for
154+
;; COPY tasks. Defaults to a max of 4 for COPY FROM and 16
155+
;; for COPY TO. However, at most (num_cores - 1) processes
156+
;; will be created.
157+
numprocesses = 16
158+
159+
;; The maximum number of failed attempts to fetch a range of data (when using
160+
;; COPY TO) or insert a chunk of data (when using COPY FROM) before giving up
161+
maxattempts = 25
162+
163+
;; How often status updates are refreshed, in seconds
164+
; reportfrequency = 0.25
165+
166+
;; An optional file to output rate statistics to
167+
; ratefile =
168+
169+
170+
171+
;; Options specific to COPY TO
172+
; [copy-to]
173+
174+
;; The maximum number token ranges to fetch simultaneously
175+
; maxrequests = 6
176+
177+
;; The number of rows to fetch in a single page
178+
; pagesize = 1000
179+
180+
;; By default the page timeout is 10 seconds per 1000 entries
181+
;; in the page size or 10 seconds if pagesize is smaller
182+
; pagetimeout = 10
183+
184+
;; Token range to export. Defaults to exporting the full ring.
185+
; begintoken =
186+
; endtoken =
187+
188+
; The maximum size of the output file measured in number of lines;
189+
; beyond this maximum the output file will be split into segments.
190+
; -1 means unlimited.
191+
; maxoutputsize = -1
192+
193+
;; The encoding used for characters
194+
; encoding = utf8
195+
196+
197+
198+
;; Options specific to COPY FROM
199+
[copy-from]
200+
201+
;; The maximum number of rows to process per second
202+
ingestrate = 1500
203+
204+
;; The maximum number of rows to import (-1 means unlimited)
205+
; maxrows = -1
206+
207+
;; A number of initial rows to skip
208+
; skiprows = 0
209+
210+
;; A comma-separated list of column names to ignore
211+
; skipcols =
212+
213+
;; The maximum global number of parsing errors to ignore, -1 means unlimited
214+
maxparseerrors = -1
215+
216+
;; The maximum global number of insert errors to ignore, -1 means unlimited
217+
maxinserterrors = -1
218+
219+
;; A file to store all rows that could not be imported, by default this is
220+
;; import_<ks>_<table>.err where <ks> is your keyspace and <table> is your table name.
221+
; errfile =
222+
223+
;; The min and max number of rows inserted in a single batch
224+
maxbatchsize = 10
225+
minbatchsize = 1
226+
227+
;; The number of rows that are passed to child worker processes from
228+
;; the main process at a time
229+
chunksize = 30
230+
231+
232+
233+
;; The options for COPY can also be specified per-table. The following
234+
;; three sections demonstrate this.
235+
236+
;; Optional table-specific options for COPY
237+
; [copy:mykeyspace.mytable]
238+
; chunksize = 1000
239+
240+
;; Optional table-specific options for COPY FROM
241+
; [copy-from:mykeyspace.mytable]
242+
; ingestrate = 20000
243+
244+
;; Optional table-specific options for COPY TO
245+
; [copy-to:mykeyspace.mytable]
246+
; pagetimeout = 30

0 commit comments

Comments
 (0)